Exemplo n.º 1
0
void ccGeoObject::generateInterior()
{
	//check interior doesn't already exist
	for (unsigned i = 0; i < getChildrenNumber(); i++)
	{
		ccHObject* c = getChild(i);
		if (ccGeoObject::isGeoObjectInterior(c))
		{
			m_interior = c;
			m_interior_id = c->getUniqueID();
			return;
		}
	}

	m_interior = new ccHObject("Interior");
	
	//give them associated property flags
	QVariantMap* map = new QVariantMap();
	map->insert("ccCompassType", "GeoInterior");
	m_interior->setMetaData(*map, true);

	//add these to the scene graph
	addChild(m_interior);
	m_interior_id = m_interior->getUniqueID();
}
Exemplo n.º 2
0
//==================================================drawBB==========================================================//
void ccHObject::drawBB(const ccColor::Rgb& col)
{
	switch (m_selectionBehavior)
	{
	case SELECTION_AA_BBOX:
		getDisplayBB_recursive(true,m_currentDisplay).draw(col);
		break;
	
	case SELECTION_FIT_BBOX: //
		{
			assert(getChildrenNumber() == 0);
			ccGLMatrix trans;
			ccBBox box = getOwnFitBB(trans); //当前版本下trans=indentity()  getOwnFitBB 返回OwnBB
			if (box.isValid()){
				glMatrixMode(GL_MODELVIEW);
				glPushMatrix();
				glMultMatrixf(trans.data());
				box.draw(col);
				glPopMatrix();
			}
		}
		break;
	
	case SELECTION_IGNORED:
		break;

	default:
		assert(false);
	}
}
Exemplo n.º 3
0
GPStreamADF::GPStreamADF(const GPFunctionTree* tree)
{
    auto root = tree->root();
    auto rootfunc = root->data().pFunc;
    GPASSERT(NULL!=rootfunc);
    auto lists = root->display();
    std::map<const GPAbstractPoint*, GPPtr<Point>> maplists;
    /*Create All Function*/
    for (auto p : lists)
    {
        auto pp = (GPFunctionTreePoint*)p;
        if (GPFunctionTreePoint::INPUT == pp->type())
        {
            GPPtr<Point> cp = new SP(NULL);
            mSources.push_back(cp);
            mInputPos.push_back(pp->data().iInput);
            maplists.insert(std::make_pair(p, cp));
        }
        else
        {
            GPPtr<Point> cp = new CP(new GPComputePoint(pp->data().pFunc));
            mFunctions.push_back((CP*)(cp.get()));
            maplists.insert(std::make_pair(p, cp));
        }
    }
    /*Dest*/
    auto rootcp = maplists.find(root)->second;
    for (int i=0; i<rootfunc->outputType.size(); ++i)
    {
        GPPtr<Point> dst = (new DP(rootfunc->outputType[i]));
        dst->connectInput(rootcp.get(), 0);
        rootcp->connectOutput(dst, i);
        mDest.push_back(dst);
    }
    /*Connect*/
    for (auto p : lists)
    {
        auto PP = maplists.find(p)->second;
        auto func = ((GPFunctionTreePoint*)p)->data().pFunc;
        size_t n = p->getChildrenNumber();
        GPASSERT(!(NULL!=func && n==0));
        for (int i=0; i<n; ++i)
        {
            auto pc = p->getChild(i);
            auto PC = maplists.find(pc)->second;
            PP->connectInput(PC.get(), i);
            PC->connectOutput(PP, 0);
            if (pc->getChildrenNumber() == 0)
            {
                SP* s = (SP*)PC.get();
                s->setType(func->inputType[i]);
            }
        }
    }
}
Exemplo n.º 4
0
//=============================================find===================================================//
ccHObject*  ccHObject::find(QString objname){

	// find the right item
	if(this->getName() == objname) return this;

	//otherwise we are going to test all children recursively
	for(unsigned i=0; i< getChildrenNumber(); ++i){
		ccHObject * match = getChild(i)->find(objname);
		if(match)return match;
	}
	return 0;

}
Exemplo n.º 5
0
//================================================find===========================================================//
ccHObject* ccHObject::find(unsigned uniqueID)
{
	//found the right item?
	if (getUniqueID() == uniqueID) //要找的物体是自身
		return this;

	//otherwise we are going to test all children recursively
	for (unsigned i=0; i<getChildrenNumber(); ++i)	{
		ccHObject* match = getChild(i)->find(uniqueID);
		if (match)
			return match;
	}

	return 0;
}
Exemplo n.º 6
0
CC_VISIBILITY_TYPE ccGenericPointCloud::testVisibility(const CCVector3& P)
{
    unsigned i=0,childNum=getChildrenNumber();

    CC_VISIBILITY_TYPE nvt, vt = ALL;

    while (i<childNum && vt==VIEWED)
    {
        if (m_children[i]->isKindOf(CC_SENSOR))
        {
            nvt = static_cast<ccSensor*>(m_children[i])->checkVisibility(P);
            vt = ccMin(vt,nvt);
        }
        ++i;
    }

	return (vt==ALL ? VIEWED : vt);
}
Exemplo n.º 7
0
bool ccGenericPrimitive::fromFile_MeOnly(QFile& in, short dataVersion, int flags)
{
	if (!ccMesh::fromFile_MeOnly(in, dataVersion, flags))
		return false;

	//HACK: first, we have to remove any 'wrongly' associated vertices cloud!
	//(this is in fact the default one - automatically created on construction)
	//while the true vertices come as a child (at least it should;)
	if (getChildrenNumber() && getChild(0)->isKindOf(CC_TYPES::POINT_CLOUD) && getChild(0) != m_associatedCloud)
		removeChild(0);

	//Transformation matrix backup (dataVersion>=21)
	if (!m_transformation.fromFile(in, dataVersion, flags))
		return false;

	//'drawing precision' (dataVersion>=21))
	if (in.read((char*)&m_drawPrecision,sizeof(unsigned))<0)
		return ReadError();

	return true;
}
Exemplo n.º 8
0
void ccGeoObject::generateLower()
{
	//check lower doesn't already exist
	for (unsigned i = 0; i < getChildrenNumber(); i++)
	{
		ccHObject* c = getChild(i);
		if (ccGeoObject::isGeoObjectLower(c))
		{
			m_lower = c;
			m_lower_id = c->getUniqueID();
			return;
		}
	}

	m_lower = new ccHObject("Lower Boundary");

	QVariantMap* map = new QVariantMap();
	map->insert("ccCompassType", "GeoLowerBoundary");
	m_lower->setMetaData(*map, true);

	addChild(m_lower);
	m_lower_id = m_lower->getUniqueID();
}
Exemplo n.º 9
0
GPMultiLayerTree::GPMultiLayerTree(const GPFunctionTree* tree)
{
    auto _root = tree->root();
    /*Find Origin Inputs*/
    int maxInputNumber = -1;
    if (GPFunctionTreePoint::OUTPUT != _root->type())
    {
        GPPtr<GPFunctionTreePoint> root = GPFunctionTree::copy(tree->root());
        mLayers.insert(std::make_pair(-1, root));
        maxInputNumber = root->maxInputPos();
    }
    else
    {
        for (int i=0; i<_root->getChildrenNumber(); ++i)
        {
            GPPtr<GPFunctionTreePoint> subRoot = GPFunctionTree::copy(GPCONVERT(const GPFunctionTreePoint, _root->getChild(i)));
            int _maxI = subRoot->maxInputPos();
            if (_maxI > maxInputNumber)
            {
                maxInputNumber = _maxI;
            }
            mLayers.insert(std::make_pair(-i-1, subRoot));
        }
    }
    int subtree_inputpos = maxInputNumber+1;
    std::vector<GPFunctionTreePoint*> workLists;
    while (true)
    {
        /*Generate Next workLists*/
        workLists.clear();
        for (auto iter :mLayers)
        {
            auto childrens = iter.second->display();
            for (auto p : childrens)
            {
                auto pp = GPCONVERT(const GPFunctionTreePoint, p);
                if (GPFunctionTreePoint::FUNCTION == pp->type())
                {
                    workLists.push_back((GPFunctionTreePoint*)pp);
                }
            }
        }
        
        /*Find same subtree*/
        std::map<GPFunctionTreePoint*, std::vector<GPFunctionTreePoint*>> equallist;
        for (size_t i=0; i<workLists.size(); ++i)
        {
            auto forcompare = workLists[i];
            bool valid = true;
            for (auto iter : equallist)
            {
                if (forcompare->isChildOf(iter.first))
                {
                    valid = false;
                }
                for (auto p : iter.second)
                {
                    if (forcompare->isChildOf(p))
                    {
                        valid = false;
                        break;
                    }
                }
                if (!valid)
                {
                    break;
                }
            }
            if (!valid)
            {
                continue;
            }
            std::vector<GPFunctionTreePoint*> equalpairs;
            for (size_t j=i+1; j<workLists.size(); ++j)
            {
                if (workLists[j]->equal(forcompare))
                {
                    equalpairs.push_back(workLists[j]);
                }
            }
            /*Valid Point, Added to equallist*/
            if (!equalpairs.empty())
            {
                std::map<GPFunctionTreePoint*, std::vector<GPFunctionTreePoint*>> filtered_equallist;
                for (auto iter : equallist)
                {
                    bool valid = true;
                    if (iter.first->isChildOf(forcompare))
                    {
                        continue;
                    }
                    for (auto p : iter.second)
                    {
                        if (p->isChildOf(forcompare))
                        {
                            valid = false;
                            break;
                        }
                    }
                    if (valid)
                    {
                        filtered_equallist.insert(std::make_pair(iter.first, iter.second));
                    }
                }
                equallist = filtered_equallist;
                equallist.insert(std::make_pair(forcompare, equalpairs));
            }
        }
        
        /*Generate New Points*/
        for (auto iter : equallist)
        {
            GPFunctionTreePoint* inputpoints = NULL;
            int inputCur = -1;
            /*Find iter.first in previous layer*/
            for (auto l : mLayers)
            {
                if (iter.first->equal(l.second.get()))
                {
                    inputpoints = new GPFunctionTreePoint(GPFunctionTreePoint::INPUT, l.first);
                    inputCur = l.first;
                    break;
                }
            }
            /*Not find exists tree, create a new one*/
            if (NULL == inputpoints)
            {
                /*replace will decRef the iter.first, addRef to avoid free*/
                iter.first->addRef();
                inputpoints = new GPFunctionTreePoint(GPFunctionTreePoint::INPUT, subtree_inputpos);
                GPPtr<GPFunctionTreePoint> match = (GPFunctionTreePoint*)iter.first;
                mLayers.insert(std::make_pair(subtree_inputpos, match));
                inputCur = subtree_inputpos;
                subtree_inputpos++;
            }
            for (auto root_iter : mLayers)
            {
                if (root_iter.first!=inputCur)
                {
                    root_iter.second->replace((GPFunctionTreePoint*)iter.first, inputpoints);
                    for (auto p : iter.second)
                    {
                        root_iter.second->replace((GPFunctionTreePoint*)p, inputpoints);
                    }
                }
            }
            inputpoints->decRef();
        }
        if (equallist.empty())
        {
            break;
        }
    }
}
Exemplo n.º 10
0
GPStreamADF::GPStreamADF(const GPMultiLayerTree* opttree)
{
    GPASSERT(NULL!=opttree);
    auto layers = opttree->layers();
    std::map<const GPFunctionTreePoint*, GPPtr<Point>> maplists;
    GPASSERT(layers.size()>=1);
    /*Create All CP*/
    for (auto iter : layers)
    {
        for (auto p : iter.second->display())
        {
            auto pp = (GPFunctionTreePoint*)p;
            if (GPFunctionTreePoint::FUNCTION == pp->type())
            {
                GPPtr<Point> cp = new CP(new GPComputePoint(pp->data().pFunc));
                mFunctions.push_back((CP*)(cp.get()));
                maplists.insert(std::make_pair(pp, cp));
            }
        }
    }
    /*Connect Already Exists CP*/
    for (auto cpiter : maplists)
    {
        auto tree = cpiter.first;
        auto output = cpiter.second;
        size_t n = tree->getChildrenNumber();
        for (int i=0; i<n; ++i)
        {
            auto _p = GPCONVERT(const GPFunctionTreePoint, tree->getChild(i));
            if (maplists.find(_p)!=maplists.end())
            {
                auto input = maplists.find(_p)->second;
                input->connectOutput(output, 0);
                output->connectInput(input.get(), i);
            }
        }
    }
    /*Create All Inputs*/
    std::map<int, std::vector<std::pair<const GPFunctionTreePoint*, int>>> inputLists;
    for (auto iter : maplists)
    {
        auto p = iter.first;
        size_t n = p->getChildrenNumber();
        for (int i=0; i<n; ++i)
        {
            auto _p = GPCONVERT(const GPFunctionTreePoint, p->getChild(i));
            if (GPFunctionTreePoint::INPUT == _p->type())
            {
                int pos = _p->data().iInput;
                if (inputLists.find(pos) == inputLists.end())
                {
                    std::vector<std::pair<const GPFunctionTreePoint*, int>> t;
                    inputLists.insert(std::make_pair(pos, t));
                }
                inputLists.find(pos)->second.push_back(std::make_pair(p, i));
            }
        }
    }
    /*Replace inputpos from layers*/
    for (auto iter : layers)
    {
        if (iter.first >= 0)
        {
            auto replacePos = iter.first;
            auto outputPoints = inputLists.find(replacePos)->second;
            GPPtr<Point> transform = new TP((int)outputPoints.size());
            mTPS.push_back((TP*)transform.get());
            GPPtr<Point> inputPoint = maplists.find(iter.second.get())->second;
            inputPoint->connectOutput(transform, 0);
            transform->connectInput(inputPoint.get(), 0);
            for (int j=0; j<outputPoints.size(); ++j)
            {
                GPPtr<Point> transform_node = new TP(1);
                mTPS.push_back((TP*)transform_node.get());
                transform->connectOutput(transform_node, j);
                transform_node->connectInput(transform.get(), 0);
                auto o_tree = outputPoints[j];
                auto o = maplists.find(o_tree.first)->second;
                o->connectInput(transform_node.get(), o_tree.second);
                transform_node->connectOutput(o, 0);
            }
            inputLists.erase(replacePos);
        }
    }
    /*Create SP*/
    GPASSERT(inputLists.size()>0);
    for (auto iter : inputLists)
    {
        for (auto v : iter.second)
        {
            auto tree = v.first;
            GPASSERT(GPFunctionTreePoint::FUNCTION == tree->type());
            auto pos = v.second;
            auto point = maplists.find(tree)->second;
            GPPtr<Point> source_point = new SP(tree->data().pFunc->inputType[pos]);
            source_point->connectOutput(point, 0);
            point->connectInput(source_point.get(), pos);
            mSources.push_back(source_point);
            mInputPos.push_back(iter.first);
        }
    }
    
    /*Create DP*/
    for (auto iter : opttree->layers())
    {
        if(iter.first < 0)
        {
            GPPtr<Point> input = maplists.find(iter.second.get())->second;
            for (size_t i=0; i<iter.second->data().pFunc->outputType.size(); ++i)
            {
                GPPtr<Point> dst = new DP(iter.second->data().pFunc->outputType[i]);
                mDest.push_back(dst);
                dst->connectInput(input.get(), 0);
                input->connectOutput(dst, 0);
            }
        }
    }
}