Example #1
0
void Team_Scene::onListUnitTouchEvent(cocos2d::Ref* ref, cocos2d::ui::Widget::TouchEventType type)
{
    if(type != Widget::TouchEventType::ENDED)
        return;
    
    Node* node = dynamic_cast<Node*>(ref);
    
    if(node->getChildByName("cover")->isVisible())
        return;
    
    int tag = node->getTag();
    
    CCLOG("onListUnitTouchEvent: %d",tag);
    
    if (m_selectedUnitWidget)
        m_selectedUnitWidget->getChildByName("select")->setVisible(false);
    
    m_selectedUnitWidget = node;
    m_selectedUnitWidget->getChildByName("select")->setVisible(true);
    
    HeroRef hero = g_gameClientManager->m_player.m_heroMap.find(tag)->second;
    assert(hero);
    
    showUnit(hero);
}
Example #2
0
mObject massesToJSON(void) {
    NodeIter &theNodes = theDomain.getNodes();
    Node *theNode;
    const Matrix *mass = NULL;

    int i, ndf;

    mObject ret;
    mArray masses;
    mValue tag, tmp;
    char tag_str[15];

    ret.clear();
    while ((theNode = theNodes()) != 0) {
        ndf = theNode->getNumberDOF();
        mass = &(theNode->getMass());
        tag = theNode->getTag();
        masses.clear();

        for (i = 0; i < ndf; i++) {
          tmp = (*mass)(i, i);
          masses.push_back(tmp);
        }
        sprintf(tag_str, "%d", tag.get_int());
        ret[tag_str] = masses;
    }
	
    return ret; 
}
Example #3
0
bool Game::init()
{
	if (!Layer::init()){
		return false;
	}

	step = 0;
	starEndFrame[0] = 18;
	starEndFrame[1] = 33;
	starEndFrame[2] = 60;

	swallowNode = Node::create();
	swallowNode->setContentSize(Director::getInstance()->getVisibleSize());
	this->addChild(swallowNode, 0);

	gameNode = CSLoader::createNode("bg6_Secene.csb");
	this->addChild(gameNode);
	//UI 
	gameUIMgr = new GameUIMgr(gameNode->getChildByTag(354), this);

	//GAME 
	gameArea = GameArea::create(gameUIMgr, guanQiaName[step]);
	gameNode->addChild(gameArea, Game::ZORDER_AREA, Game::TAG_AREA);

	//STAR
	Node* starNode = gameNode->getChildByTag(962);
	starNode->setZOrder(2);
	starAtl = dynamic_cast<ActionTimeline*>(starNode->getActionByTag(starNode->getTag()));
	starAtl->gotoFrameAndPause(0);

	initTouch();

	return true;
}
Example #4
0
void MainLayer::menuCloseCallback(Ref* pSender)
{
    Node * node = (Node *)pSender;

    switch(node->getTag()) {
    case MENU_SINGLE_GAME_TAG:
        SimpleAudioEngine::getInstance()->playEffect("audio/system/choose-item.mp3");
        //startServer();
        CCLOG("single clicked");
        Director::getInstance()->pushScene(Table::scene());
        break;
    case MENU_MULTI_GAME_TAG:
        SimpleAudioEngine::getInstance()->playEffect("audio/system/choose-item.mp3");
        //startClient();
        CCLOG("multi clicked");
        //Director::getInstance()->pushScene(sgs::scene::Lobby::scene());
        break;
    case MENU_ABOUT_GAME_TAG:
        SimpleAudioEngine::getInstance()->playEffect("audio/system/choose-item.mp3");
        CCLOG("about clicked");
        //Director::getInstance()->pushScene(AboutUs::scene());
        break;
    case MENU_EXIT_GAME_TAG:
        Director::getInstance()->end();
        break;
    }
}
Example #5
0
void MainMenu::touchEvent(Ref *pSender, TouchEventType type)
{
    switch (type)
    {
        case TOUCH_EVENT_ENDED:

			if (pSender)
			{
				Node *node = static_cast<Node*>(pSender);
				if (node)
				{
					switch (node->getTag())
					{
					case 1:
						gotoBattleScene();
						break;
					case 2:
						endGame();
						break;
					default:
						break;
					}
				}
			}

            break;
            
        default:
            break;
    }
}
Example #6
0
mObject nodesDispToJSON(void) {
    NodeIter &theNodes = theDomain.getNodes();
    Node *theNode;
    const Vector *nodalResponse;
    int size;
    int i;

    mObject disp_field, result;
    mArray nodal_disps;
    mValue tag, disp;
    char tag_str[15];

    // TODO: The field 'time' shouldn't be here, but old SketchIT depends on it, for compatibilty.
    mValue ctime = theDomain.getCurrentTime();
    result["time"] = ctime;

    disp_field.clear();
    while ((theNode = theNodes()) != 0) {
        nodalResponse = theNode->getResponse(Disp);
        size = nodalResponse->Size();

        nodal_disps.clear();
        for (i = 0; i < size; i++) {
            disp = (*nodalResponse)(i);
            nodal_disps.push_back(disp);
        }

        tag = theNode->getTag();
        sprintf(tag_str, "%d", tag.get_int());        
        disp_field[tag_str] = nodal_disps;
    }
    result["disp"] = disp_field;
    return result;
};
Node* SceneReader::nodeByTag(Node *parent, int tag)
{		
    if (parent == nullptr)
    {
        return nullptr;
    }
    Node *_retNode = nullptr;
    Vector<Node*>& Children = parent->getChildren();
    Vector<Node*>::iterator iter = Children.begin();
    while (iter != Children.end())
    {
        Node* pNode = *iter;
        if(pNode != nullptr && pNode->getTag() == tag)
        {
            _retNode =  pNode;
            break;
        }
        else
        {
            _retNode = nodeByTag(pNode, tag);
            if (_retNode != nullptr)
            {
                break;
            }

        }
        ++iter;
    }
    return _retNode;
}
Example #8
0
mObject nodesToJSON(void) {
    NodeIter &theNodes = theDomain.getNodes();
    Node *theNode;
    const Vector *nodalCrds = NULL;
    int size;
    int i, ndf;

    mObject nodes;
    mArray coords;
    mValue tag, coord;
    char tag_str[15];

    nodes.clear();
    while ((theNode = theNodes()) != 0) {
        nodalCrds = &(theNode->getCrds());
        ndf = theNode->getNumberDOF();
        tag = theNode->getTag();
        size = nodalCrds->Size();
        coords.clear();
        for (i = 0; i < size; i++) {
            coord = (*nodalCrds)(i);
            coords.push_back(coord);
        }
        sprintf(tag_str, "%d", tag.get_int());
        nodes[tag_str] = coords;
    }
	
    return nodes; 
}
Example #9
0
void ShowPhoneui::event_menu_phone(Ref* pSender)
{
    Node* node = (Node*)pSender;
    CCLOG("tag %d", node->getTag());

    CSceneManager::getInstance()->replaceScene(
        CCSceneExTransitionFade::create(0.5f, LoadScene("Main::Mainui")));
}
Example #10
0
void PauseLayer::startGame(Ref* node)
{
	//CCLOG("START!");
	//GAMEDATA::getInstance()->init();
	//Director::getInstance()->replaceScene(GameScene::create());
    
    Node* pender = (Node*)node;
    
    int tag = pender->getTag();
    
    CCLOG("btn tag = %d",tag);
    
    Scene* scene = (Scene*)this->getParent();
    
    GameLayer* gameLayer = (GameLayer*)scene->getChildByTag(999);
    
    TopMenu* topMenu = (TopMenu*)gameLayer->getChildByTag(9999);
    
    Menu* menuPause = (Menu*)topMenu->getChildByTag(100);
    
    menuPause->setEnabled(true);
    
    switch (tag)
    {
        case 10:
        {
            this->removeSelfListener();

            //主菜单
            Director::getInstance()->replaceScene(MenuScene::create());
            
            this->removeFromParent();
        }
            break;
        case 11:
        {
            Director::getInstance()->getEventDispatcher()->removeEventListener(listener);
            //重新开始
            EventCustom eventReset = EventCustom("Game_Reset");
            Director::getInstance()->getEventDispatcher()->dispatchEvent(&eventReset);
            //从头来
            
            this->removeFromParent();
        }
            break;
        case 12:
        {
            Director::getInstance()->getEventDispatcher()->removeEventListener(listener);
            //继续游戏
            this->removeFromParent();
        }
            break;
            
        default:
            break;
    }

}
Example #11
0
void PopLayer::buttonCallback(Ref* pSender)
{
    Node* node = dynamic_cast<Node*>(pSender);
    log("touch tag: %d", node->getTag());
    if (m_callback && m_callbackListener){
        (m_callbackListener->*m_callback)(node);
    }
    this->removeFromParent();
}
Example #12
0
void PopupLayer::buttonCallback(cocos2d::CCObject *pSender)
{
    Node* node = dynamic_cast<Node*>(pSender);
    CCLog("touch tag: %d", node->getTag());
    if (m_callback && m_callbackListener){
        (m_callbackListener->*m_callback)(node);
    }
   // this->removeFromParent();
}
Example #13
0
void GameLayer::onPunishCatSelected(Ref* sender) {
    if (LogicalEngine::getInstance()->isRoomOwner()) {
        Node * item = (Node*)sender;
        PunishCat type = (PunishCat)(item->getTag());
        setSelectedPunishCat(type);
        hidePunishCat();
        
        LogicalEngine::getInstance()->setPunishSetting(mSelectedPunishCat, mSelectedPunishType);
        log((string(__FUNCTION__)+"Selected type:%d").c_str(), (int)type);
    }
}
Example #14
0
void BattleCardSelect::MBtnClicked(cocos2d::Ref* pSender)
{
	Node * tnode = static_cast<Node *>(pSender);
	const int ttag = tnode->getTag();

	if (m_btnCallback != nullptr)
	{
		m_btnCallback(ttag-81);
	}
	CloseWindow();
}
Example #15
0
void Node::removeChild(int tag)
{
	auto itor = m_childList.begin();
	for (; itor != m_childList.end(); ++itor)
	{
		Node* node = *itor;
		if (node->getTag() == tag)
		{
			updateItor(m_childList.erase(itor));
			return;
		}
	}
}
Example #16
0
void ResultLayer::onClick(cocos2d::Ref* pSender)
{
    CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("Sound/Button.mp3");
    Node* node = (Node*)pSender;
    switch (node->getTag()) {
        case kResultRestartTag:
            if (getDelegate())
            {
                getDelegate()->restartGame();
            }
            break;
            
        default:
            break;
    }
    
}
Example #17
0
int 
GSA_Recorder::record(int commitTag, double timeStamp)
{

  if (deltaT == 0.0 || timeStamp >= nextTimeStampToRecord) {
      
    if (deltaT != 0.0) 
      nextTimeStampToRecord = timeStamp + deltaT;

    counter++;

    theFile << "ANAL_CASE\t" << counter << "\tStep" << counter << "\tL" << counter << 
      "\tGSS\tSTATIC\tPOST\t" << counter << "\topensees\t" << "20030204165318	0" << endln;

    theFile << "!\n!RESULTS FOR ANALYSIS CASE\t" << counter << "\n!\n";

    // spit out nodal displacements
    NodeIter &theNodes = theDomain->getNodes();
    Node *theNode;
    while ((theNode=theNodes()) != 0) {
      int nodeTag = theNode->getTag();
      const Vector &disp = theNode->getTrialDisp();
      if (ndm == 3 && ndf == 6) {
	theFile << "DISP\t" << nodeTag << "\t" << counter;
	for (int i=0; i<ndm; i++)
	  theFile << "\t" << disp(i);
	theFile << endln;
	theFile << "ROTN\t" << nodeTag << "\t" << counter;
	for (int j=0; j<ndm; j++)
	  theFile << "\t" << disp(ndm+j);
	theFile << endln;
      }
    }

    ElementIter &theElements = theDomain->getElements();
    Element *theElement;
    while ((theElement=theElements()) != 0) {
      theElement->Print(theFile, (counter+1)*-1);  // starts at -2, as already using -1

    }
  }
  
  return 0;
}
Example #18
0
//! @brief Returns an ID containing the tags of all nodes added to the subdomain
//! as external nodes and have yet to be removed from the subdomain.
const XC::ID &XC::Subdomain::getExternalNodes(void) const
  {
    // first we check that extNodes exists and is of correct size
    int numExt = externalNodes->getNumComponents();
    if(!extNodes)
      {
        extNodes= new ID(numExt);
        if(extNodes == 0 || extNodes->Size() != numExt)
          {
            std::cerr << Domain::getClassName() << "::" << __FUNCTION__
		      << "; ran out of memory for size "
		      << numExt << std::endl;
            exit(-1);
          }
      }

    if(extNodes->Size() != numExt)
      {
        delete extNodes;
        extNodes = new ID(numExt);
        if(extNodes == 0 || extNodes->Size() != numExt)
          {
            std::cerr << Domain::getClassName() << "::" << __FUNCTION__
		      << "; ran out of memory for size: "
		      << numExt << std::endl;
            exit(-1);
          }
      }

    // we now set the values of extNodes to be the node tags of the
    // external nodes

    NodeIter &theExtNodes = this->getExternalNodeIter();
    Node *nodPtr;
    int cnt = 0;

    while ((nodPtr = theExtNodes()) != nullptr)
      (*extNodes)(cnt++) = nodPtr->getTag();

    // done
    ID &res = *extNodes;
    return res;
  }
Example #19
0
int
Mesh::nextNodeTag()
{
    Domain* domain = OPS_GetDomain();
    if (domain == 0) {
        opserr << "WARNING: domain is not created\n";
        return -1;
    }

    NodeIter& nodes = domain->getNodes();
    Node* node = 0;
    int ndtag = 0;

    while((node = nodes()) != 0) {
        ndtag = node->getTag();
    }

    return ndtag+1;
}
Example #20
0
void Analyzer::printresults()
{
	output<<"\n";
	output<<" ---- result of analysis -----\n";
	output<<"\n";
	output.setf(ios::right);
	output.setf(ios::scientific, ios::floatfield);
	NodeIter& theNodes = theDomain->getNodes();
	Node* theNode;
	while((theNode = theNodes()) != 0){
		int tag=theNode->getTag();
		int ndof=theNode->getNumberDOF();
		Vector Disp=theNode->getDisp();
		output << setw(10) << tag;
		for(int i=0; i<ndof; i++)
			output << setw(15) << setprecision(5) << Disp(i);
		output<<"\n";
	}
	output.flush();
}
void
UniformExcitation::setDomain(Domain *theDomain) 
{
  this->LoadPattern::setDomain(theDomain);

  // now we go through and set all the node velocities to be vel0 
  // for those nodes not fixed in the dirn!
  if (vel0 != 0.0) {

    SP_ConstraintIter &theSPs = theDomain->getSPs();
    SP_Constraint *theSP;
    ID constrainedNodes(0);
    int count = 0;
    while ((theSP=theSPs()) != 0) {
      if (theSP->getDOF_Number() == theDof) {
	constrainedNodes[count] = theSP->getNodeTag();
	count++;
      }
    }


    NodeIter &theNodes = theDomain->getNodes();
    Node *theNode;
    Vector newVel(1);
    int currentSize = 1;
    while ((theNode = theNodes()) != 0) {
      int tag = theNode->getTag();
      if (constrainedNodes.getLocation(tag) < 0) {
	int numDOF = theNode->getNumberDOF();
	if (numDOF != currentSize) 
	  newVel.resize(numDOF);
	
	newVel = theNode->getVel();
	newVel(theDof) = vel0;
	theNode->setTrialVel(newVel);
	theNode->commitState();
      }
    }
  }
}
Example #22
0
char *theNodesToJson(char *strptr) {
    NodeIter &theNodes = theDomain.getNodes();
    Node *theNode;
    const Vector *nodalCrds = NULL;
    char buffer[40];
//	double ctime = theDomain.getCurrentTime();
    int size;
    int nn = theDomain.getNumNodes();
    int nid;
    int i, j;

    sprintf(buffer, "\"theNodes\":{");
    strcat(strptr, buffer);
    j = 0;
    while ((theNode = theNodes()) != 0) {
        j++;
        nodalCrds = &(theNode->getCrds());
        nid = theNode->getTag();
        size = nodalCrds->Size();
        sprintf(buffer, "\"%d\":[", nid);
        strcat(strptr, buffer);

        for (i = 0; i < size; i++) {
            if (i == size - 1) {
                sprintf(buffer, "%15.15f", (*nodalCrds)(i));
            } else {
                sprintf(buffer, "%15.15f,", (*nodalCrds)(i));
            }
            strcat(strptr, buffer);
        }
        if (j < nn) {
            strcat(strptr, "],");
        } else {
            strcat(strptr, "]");
        }
    }
    strcat(strptr, "}");
    return strptr;
}
Example #23
0
void BattleCardSelect::LoadNodeCallback(cocos2d::Ref * lnode)
{
	Node * tnode = static_cast<Node *>(lnode);
	const int ttag = tnode->getTag();
	switch (ttag)
	{
	case 82:
	case 83:
	case 84:
	case 85:
	case 86:
	case 87:
	case 88:
	case 89:
	case 90:
	case 91:
	{
		m_cardBtn[ttag - 82] = static_cast<ui::Button *>(tnode);
		m_cardBtn[ttag - 82]->addClickEventListener(CC_CALLBACK_1(BattleCardSelect::MBtnClicked, this));
	}
	break;
	}
}
Example #24
0
int
TetMesh::remesh(double alpha)
{
    int ndm = OPS_GetNDM();
    if (ndm != 3) {
	opserr << "WARNING: TetMesh::remesh is only for 3D problem\n";
	return -1;
    }
    Domain* domain = OPS_GetDomain();
    if (domain == 0) {
        opserr << "WARNING: domain is not created\n";
        return -1;
    }

    // get all nodes
    std::map<int, std::vector<int> > ndinfo;
    TaggedObjectIter& meshes = OPS_getAllMesh();
    ID nodetags;
    Mesh* msh = 0;
    while((msh = dynamic_cast<Mesh*>(meshes())) != 0) {

        int id = msh->getID();
        int mtag = msh->getTag();

        if (id == 0) continue;

        // get bound nodes
        const ID& tags = msh->getNodeTags();
        for (int i=0; i<tags.Size(); ++i) {
            std::vector<int>& info = ndinfo[tags(i)];
            info.push_back(mtag);
            info.push_back(id);
            nodetags.insert(tags(i));
        }

        // get internal nodes
        const ID& newtags = msh->getNewNodeTags();
        for (int i=0; i<newtags.Size(); ++i) {
            std::vector<int>& info = ndinfo[newtags(i)];
            info.push_back(mtag);
            info.push_back(id);
            nodetags.insert(newtags(i));
        }
    }

    if (nodetags.Size() == 0) return 0;

    // calling mesh generator
    TetMeshGenerator gen;
    int nodecounter = nextNodeTag();
    for(int i=0; i<nodetags.Size(); ++i) {

        // get node
        Node* theNode = domain->getNode(nodetags(i));
        if(theNode == 0) {
            opserr<<"WARNING: node "<<nodetags(i)<<" is not defined\n";
            return -1;
        }
        const Vector& crds = theNode->getCrds();
        const Vector& disp = theNode->getTrialDisp();
        if(crds.Size() < ndm || disp.Size() < ndm) {
            opserr<<"WARNING: ndm < 3 or ndf < 3\n";
            return -1;
        }

	// create pc if not
	Pressure_Constraint* thePC = domain->getPressure_Constraint(nodetags(i));
	if(thePC != 0) {
	    thePC->setDomain(domain);
	} else {

	    // create pressure node
	    Node* pnode = 0;
	    pnode = new Node(nodecounter++, 1, crds(0), crds(1), crds(2));
	    if (pnode == 0) {
		opserr << "WARNING: run out of memory -- BgMesh::gridNodes\n";
		return -1;
	    }
	    if (domain->addNode(pnode) == false) {
		opserr << "WARNING: failed to add node to domain -- BgMesh::gridNodes\n";
		delete pnode;
		return -1;
	    }

	    thePC = new Pressure_Constraint(nodetags(i), pnode->getTag());
	    if(thePC == 0) {
		opserr<<"WARNING: no enough memory for Pressure_Constraint\n";
		return -1;
	    }
	    if (domain->addPressure_Constraint(thePC) == false) {
		opserr << "WARNING: failed to add PC to domain -- BgMesh::gridNodes\n";
		delete thePC;
		return -1;
	    }
	}

        // add point
        gen.addPoint(crds(0)+disp(0), crds(1)+disp(1), crds(2)+disp(2), 0);
    }

    // meshing
    gen.remesh(alpha);

    // get elenodes
    std::map<int,ID> meshelenodes;
    for(int i=0; i<gen.getNumTets(); i++) {

        // get points
        int p1,p2,p3,p4;
        gen.getTet(i,p1,p2,p3,p4);

        // get nodes
        int nds[4];
        nds[0] = nodetags(p1);
        nds[1] = nodetags(p2);
        nds[2] = nodetags(p3);
	nds[3] = nodetags(p4);

        // check if all nodes in same mesh
        std::vector<int>& info1 = ndinfo[nds[0]];
        int mtag = 0, id = 0;
        bool same = false;
        for (int k=0; k<(int)info1.size()/2; ++k) {
            // check if any mesh of node 1 is same for another three nodes
            mtag = info1[2*k];
            id = info1[2*k+1];

            int num = 0;
            for (int j=1; j<4; ++j) {
                std::vector<int>& infoj = ndinfo[nds[j]];
                for (int kj=0; kj<(int)infoj.size()/2; ++kj) {
                    int mtagj = infoj[2*kj];
                    if (mtag == mtagj) {
                        ++num;
                        break;
                    }
                }

            }
            if (num == 3) {
                same = true;
                break;
            }
        }

        // nodes in different mesh
        if (!same) {
            mtag = 0;
            id = 0;
            for (int j=0; j<4; ++j) {
                std::vector<int>& info = ndinfo[nds[j]];
                for (int k=0; k<(int)info.size()/2; ++k) {
                    if (info[2*k+1] < id) {
                        if (dynamic_cast<TetMesh*>(OPS_getMesh(info[2*k])) != 0) {
                            mtag = info[2*k];
                            id = info[2*k+1];
                        }
                    }
                }
            }
        }

        // if all connected to structure
        if (id >= 0) continue;

        // add elenodes to its mesh
        ID& elenodes = meshelenodes[mtag];
        for (int j=0; j<4; ++j) {
            elenodes[elenodes.Size()] = nds[j];
        }
    }

    // creat elements
    for (std::map<int,ID>::iterator it=meshelenodes.begin();
	 it!=meshelenodes.end(); ++it) {

        int mtag = it->first;
        ID& elenodes = it->second;

        msh = OPS_getMesh(mtag);
        if (msh != 0) {

            int id = msh->getID();

            // remove mesh for id<0
            if (id < 0) {
                if (msh->clearEles() < 0) {
                    opserr << "WARNING: failed to clear element in mesh"<<mtag<<"\n";
                    return -1;
                }

                if (msh->newElements(elenodes) < 0) {
                    opserr << "WARNING: failed to create new elements in mesh"<<mtag<<"\n";
                    return -1;
                }
            }
        }
    }

    return 0;
}
Example #25
0
int
TriMesh::mesh(int rtag, double size, const ID& nodes,const ID& bound)
{
    // check
    if(size <= 0) {
	opserr<<"WARNING: mesh size <= 0\n";
	return -1;
    }
    if(nodes.Size() < 3) {
	opserr<<"WARNING: input number of nodes < 3\n";
	return -1;
    }
    if(bound.Size() < nodes.Size()) {
	opserr<<"WARNING: the number of boundary ID < number of nodes\n";
	return -1;
    }
    
    // calling mesh generator
    TriangleMeshGenerator gen;
    for(int i=0; i<nodes.Size(); i++) {
	// get node
	Node* theNode = theDomain->getNode(nodes(i));
	if(theNode == 0) {
	    opserr<<"WARNING: node "<<nodes(i)<<" is not defined\n";
	    return -1;
	}
	const Vector& crds = theNode->getCrds();
	if(crds.Size() < 2) {
	    opserr<<"WARNING: ndm < 2\n";
	    return -1;
	}
	// add point
	gen.addPoint(crds(0), crds(1));

	// add segment
	int p1 = i;
	int p2;
	if(i==nodes.Size()-1) {
	    p2 = 0;
	} else {
	    p2 = i+1;
	}
	if(bound(i) == 0) {
	    gen.addSegment(p1,p2,-1);
	} else {
	    gen.addSegment(p1,p2,0);
	}
    }

    // meshing
    gen.mesh(size*size*0.5);

    // get node tag
    NodeIter& theNodes = theDomain->getNodes();
    Node* theNode = theNodes();
    int currtag = 0;
    if(theNode != 0) currtag = theNode->getTag();

    // get nodes
    ID regnodes(0,gen.getNumPoints());
    ID ptmark(gen.getNumPoints());
    ID ptnode(gen.getNumPoints());
    int index = 0;
    for(int i=0; i<nodes.Size(); i++) {
	int j = i-1;
	if(i==0) j = nodes.Size()-1;
	if(bound(i)!=0 && bound(j)!=0) {
	    regnodes[index++] = nodes(i);
	    ptmark(i) = 0;
	} else {
	    ptmark(i) = -1;
	}
	ptnode(i) = nodes(i);
    }
    for(int i=nodes.Size(); i<gen.getNumPoints(); i++) {
	// get point
	double x, y;
	int mark = 0;
	gen.getPoint(i,x,y,mark);

	// if on unwanted boundary
	if(mark == -1) {
	    ptmark(i) = -1;
	    continue;
	} else {
	    ptmark(i) = 0;
	}

	// create node
	Node* node = new Node(--currtag,ndf,x,y);
	if(node == 0) {
	    opserr<<"run out of memory for creating Node\n";
	    return -1;
	}
	if(theDomain->addNode(node) == false) {
	    opserr<<"Failed to add node to domain\n";
	    delete node;
	    return -1;
	}

	// add to region
	regnodes[index++] = currtag;
	ptnode(i) = currtag;
    }

    // get elenodes
    ID regelenodes(0,gen.getNumTriangles());
    index = 0;
    for(int i=0; i<gen.getNumTriangles(); i++) {
	int p1,p2,p3;
	gen.getTriangle(i,p1,p2,p3);
	if(ptmark(p1)==0 && ptmark(p2)==0 && ptmark(p3)==0) {
	    regelenodes[index++] = ptnode(p1);
	    regelenodes[index++] = ptnode(p2);
	    regelenodes[index++] = ptnode(p3);
	}
    }

    // get region
    MeshRegion* theRegion = theDomain->getRegion(rtag);
    if(theRegion == 0) {
	theRegion = new MeshRegion(rtag);
	if(theDomain->addRegion(*theRegion) < 0) {
	    opserr<<"WARNING: failed to add region\n";
	    return -1;
	}
    }

    // add to region
    theRegion->setNodes(regnodes);
    
    return 0;
}
Example #26
0
void DecorateScene::onItemsThingClicked(cocos2d::Ref *pRef, Widget::TouchEventType ttouch) {
    if (ttouch == Widget::TouchEventType::ENDED) {
        if (itemScrollView->getNumberOfRunningActions() != 0) {
            return;
        }
        Node* pNode = dynamic_cast<Node*>(pRef);
        if (pNode->getChildByTag(kLockTags) != nullptr) {
            //goto shop layer
            pushTheScene<ShopScene>();
            return;
        }
        if (decorateItemCantBeClick == true) {
            return;
        }
        
        string decorateType = pNode->getName();
        string filePath = "decorate/"+decorateType+"/"+decorateType+convertIntToString(pNode->getTag()) + ".png";
        Vec2 pos = Vec2::ZERO;
        Vec2 startPos = pNode->convertToWorldSpace(Vec2(0, 0)) + Vec2(pNode->getContentSize().width/2.0, pNode->getContentSize().height/2.0);
        int localZorder = 0;
        Node* decorateItem = nullptr;
        if (decorateType == "bg") {
            filePath.replace(filePath.size() - 4, filePath.size() - 1, ".jpg");
            m_pBg->setTexture(filePath);
            allItems.bgName = filePath;
            SoundPlayer::getInstance()->playDecorateEffect();
            
        }else if (decorateType == "breakfast food"){
            pos = breakFast->getPosition();
            localZorder = 2;
            breakFast->setOpacity(0);
            breakFast->setTexture(filePath);
            allItems.breakfastName = filePath;
            breakFast->setPosition(startPos);
            breakFast->setZOrder(50);
            decorateItem = breakFast;
            
        }else if (decorateType == "mascot sticker"){
            pos = mascot->getPosition();
            mascot->runAction(Sequence::create(FadeOut::create(0.2), CallFunc::create([=]{
                mascot->changeItemTexture(filePath);
            }),FadeIn::create(0.3f),CallFunc::create([=]{
                if (pos != Vec2::ZERO) {
                    ParticleSystemQuad* _partilce = ParticleSystemQuad::create("decorate/starBlink.plist");
                    _partilce->setPosition(pos);
                    addChild(_partilce, 30);
                    _partilce->setAutoRemoveOnFinish(true);
                    SoundPlayer::getInstance()->playDecorateEffect();
                }
            }), NULL));
            
            allItems.mascotName = filePath;
 
        }else if (decorateType == "spoon") {
            localZorder = 10;
            pos = spoon->getPosition();
            spoon->setOpacity(0);
            spoon->changeItemTexture(filePath);
            allItems.spoonName = filePath;
            spoon->setPosition(startPos);
            spoon->setZOrder(50);
            decorateItem = spoon;
        }else if (decorateType == "cereal box"){
            pos = cerealBox->getPosition();
            cerealBox->setTexture(filePath);
            allItems.cerealName = filePath;
            if (pos != Vec2::ZERO) {
                ParticleSystemQuad* _partilce = ParticleSystemQuad::create("decorate/starBlink.plist");
                _partilce->setPosition(pos);
                addChild(_partilce, 30);
                _partilce->setAutoRemoveOnFinish(true);
                SoundPlayer::getInstance()->playDecorateEffect();
            }
        }else {
            FillMaterialModel* ptool = FillMaterialModel::create(filePath, true);
            ptool->setPosition(startPos);
            ptool->setOpacity(0);
            canEatLayer->addChild(ptool, 50);
        
            localZorder = 12;
            decorateItem = ptool;
            pos = Vec2(STVisibleRect::getCenterOfScene().x, tableMaxy-100);
        }
        if (decorateItem != nullptr) {
            log("the position us %.2f, %.2f", pos.x, pos.y);
            log("the localZorder is %d", localZorder);
            decorateItemCantBeClick = true;
            decorateItem->runAction(Sequence::create(FadeIn::create(0.05f),EaseSineInOut::create(MoveTo::create(0.5, pos)), CallFunc::create(std::bind(&Node::setLocalZOrder, decorateItem, localZorder)), CallFunc::create([=]{
                if (pos != Vec2::ZERO) {
                    ParticleSystemQuad* _partilce = ParticleSystemQuad::create("decorate/starBlink.plist");
                    _partilce->setPosition(pos);
                    addChild(_partilce, 30);
                    _partilce->setAutoRemoveOnFinish(true);
                    SoundPlayer::getInstance()->playDecorateEffect();
                    decorateItemCantBeClick = false;
                }
            }),NULL));
        }
        
    }
}
Example #27
0
GSA_Recorder::GSA_Recorder(Domain &theDom, 
			   const char *fileName, 
			   const char *title1,
			   const char *title2,
			   const char *title3,
			   const char *jobno,
			   const char *initials,
			   const char *spec,
			   const char *currency,
			   const char *length,
			   const char *force,
			   const char *temp,
			   double dT)
: Recorder(RECORDER_TAGS_GSA_Recorder),
  theDomain(&theDom), ndm(3), ndf(6), counter(0), deltaT(dT), nextTimeStampToRecord(0.0)
{
  // open file 
  if (theFile.setFile(fileName, OVERWRITE) < 0) {
    opserr << "WARNING - GSA_Recorder::GSA_Recorder()";
    opserr << " - could not open file " << fileName << endln;
    exit(-1);
  } 

  // spit out header data
  if (title1 != 0)
    theFile << "TITLE\t" << title1;
  else
    theFile << "TITLE\t" << "No Title";


  if (title2 != 0)
    theFile << "\t" << title2;
  else
    theFile << "\t" << "BLANK";


  if (title3 != 0)
    theFile << "\t" << title3;
  else
    theFile << "\t" << "BLANK";  


  if (jobno != 0)
    theFile << "\t" << jobno;
  else
    theFile << "\t" << "0000";


  if (initials != 0)
    theFile<< "\t" << initials << endln;
  else
    theFile << "\t" << "ANOTHER\n";  


  if (spec != 0)
    theFile << "SPEC\t" << spec << endln;


  if (currency != 0)
    theFile << "CURRENCY\t" << currency << endln;


  if (length != 0)
    theFile << "UNIT_DATA\tLENGTH\t" << length << endln; 


  if (force != 0)
    theFile << "UNIT_DATA\tFORCE\t" << force << endln;


  if (temp != 0)
    theFile << "UNIT_DATA\tTEMP\t" << temp << endln;


  // spit out nodal data
  NodeIter &theNodes = theDomain->getNodes();
  Node *theNode;
  while ((theNode=theNodes()) != 0) {
    int nodeTag = theNode->getTag();
    theFile << "NODE\t" << nodeTag;
    const Vector &crds = theNode->getCrds();
    if (crds.Size() != ndm) {
      opserr << "WARNING - GSA_Recorder::GSA_Recorder() - node: " <<  nodeTag ;
      opserr << " has invalid number of coordinates, expecting: " << ndm << " got: " << crds.Size() << endln;
      exit(-1);
    }
    const Vector &disp = theNode->getTrialDisp();
    if (disp.Size() != ndf) {
      opserr << "WARNING - GSA_Recorder::GSA_Recorder() - node: " <<  nodeTag ;
      opserr << " has invalid number of dof, expecting: " << ndf << " got: " << disp.Size() << endln;
      exit(-1);
    }
    for (int i=0; i<ndm; i++)
      theFile << "\t" << crds(i);
    theFile << endln;
  }
  
  
  // open file and spit out the initial data
  SP_ConstraintIter &theSPs = theDomain->getSPs();
  SP_Constraint *theSP;
  ID theConstrainedNodes(0,6);
  ID theSpMatrix(0, 6*ndf);
  int numNodesWithSP = 0;
  while ((theSP=theSPs()) != 0) {
    int nodeTag =  theSP->getNodeTag();
    int location = theConstrainedNodes.getLocation(nodeTag);
    if (location < 0) {
      theConstrainedNodes[numNodesWithSP] = nodeTag;
      for (int i=0; i<ndf; i++)
	theSpMatrix[numNodesWithSP*ndf+i] = 0;	  
      location = numNodesWithSP++;
    }
    int id = theSP->getDOF_Number();
    theSpMatrix[location*ndf + id] = 1;
  }
  
  for (int j=0; j<numNodesWithSP; j++) {
    theFile << "SPC\t" <<  theConstrainedNodes[j] << "\t0";
    for (int i=0; i<ndf; i++)
      theFile << "\t" << theSpMatrix[j*ndf+i];
    theFile << endln;
  }
  
  ElementIter &theElements = theDomain->getElements();
  Element *theElement;
  while ((theElement=theElements()) != 0) {
    theElement->Print(theFile, -1);
  }

}
Example #28
0
// on "init" you need to initialize your instance
bool BookCityScene::init()
{
	//////////////////////////////
	// 1. super init first
	if (!Layer::init())
	{
		return false;
	}

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();
	
	int allCount = 4;
	auto node = (Layer*)CSLoader::createNode(BABYCENTER_BOOKCITY_CSB);
	auto leftColumn = (Sprite*)node->getChildByName(BABYCENTER_FIND_LEFTCOLUMN);
	leftColumn->setTag(100);
	auto rightColumn = (Sprite*)node->getChildByName(BABYCENTER_FIND_RIGHTCOLUMN);
	rightColumn->setTag(101);
	auto backWall = (Sprite*)node->getChildByName(BABYCENTER_FIND_BACKWALL);


	auto floor = (Sprite*)node->getChildByName(BABYCENTER_FIND_FLOOR);
	floor->setTag(103);
	

	addChild(node);

	//ScrollView
	auto _scrollView = (ui::ScrollView*)node->getChildByName(BABYCENTER_BOOKCITY_SCROLLVIEW);
	_scrollView->setScrollBarEnabled(false);
	_scrollView->setBounceEnabled(true);
	//this->addButtonOnScrollView();

    int bigBook = 0;
    int smallBook = 0;
    
	//推荐书籍	
	auto bookNode1 = (Node*)CSLoader::createNode(BABYCENTER_TUIJIANLAYER_CSB);
	bookNode1->setTag(BOOK_STORE_BORDER_BIG);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
	vecAll.pushBack(bookNode1);
    

	//排行书籍
	for (int i = 0; i < allCount; i++)
	{
		auto bookNode2 = (Node*)CSLoader::createNode(BABYCENTER_PAIHANGLAYER_CSB);
		bookNode2->setTag(BOOK_STORE_BORDER_SMALL);
		auto scoUp = (ui::ImageView*)bookNode2->getChildByName(BABYCENTER_FIND_YILAPAIHANG_TWO);
		scoUp->setTouchEnabled(true);
		scoUp->setSwallowTouches(false);
		scoUp->addClickEventListener([=](Ref* sender)
		{
			CCScaleTo* sc1 = CCScaleTo::create(0.3, 1.25);
			CCRotateTo* ro1 = CCRotateTo::create(0.3, 10);
			CCSpawn* sp1 = CCSpawn::create(sc1, ro1, NULL);

			CCScaleTo* sc2 = CCScaleTo::create(0.1, 1.2);
			CCRotateTo* ro2 = CCRotateTo::create(0.1, -8);
			CCSpawn* sp2 = CCSpawn::create(sc2, ro2, NULL);

			CCScaleTo* sc3 = CCScaleTo::create(0.1, 1.15);
			CCRotateTo* ro3 = CCRotateTo::create(0.1, 6);
			CCSpawn* sp3 = CCSpawn::create(sc3, ro3, NULL);

			CCScaleTo* sc4 = CCScaleTo::create(0.15, 1.1);
			CCRotateTo* ro4 = CCRotateTo::create(0.15, -4);
			CCSpawn* sp4 = CCSpawn::create(sc4, ro4, NULL);

			CCScaleTo* sc5 = CCScaleTo::create(0.1, 1.1);
			CCRotateTo* ro5 = CCRotateTo::create(0.1, 2);
			CCSpawn* sp5 = CCSpawn::create(sc5, ro5, NULL);

			CCScaleTo* sc6 = CCScaleTo::create(0.25, 1);
			CCRotateTo* ro6 = CCRotateTo::create(0.25, 0);
			CCSpawn* sp6 = CCSpawn::create(sc6, ro6, NULL);

			CCCallFunc *callFunc = CCCallFunc::create([=]() {


				_scrollView->runAction(MoveBy::create(0.8f, Point(0, 1430)));
				backWall->runAction(MoveBy::create(0.8f, Point(0, 1430)));
				floor->runAction(MoveBy::create(1.2f, Point(0, -320)));
				leftColumn->runAction(MoveBy::create(1.2f, Point(-200, 0)));
				rightColumn->runAction(MoveBy::create(1.2f, Point(200, 0)));
			});
			CCCallFunc *callFunc2 = CCCallFunc::create([=]() {
				auto director = Director::getInstance();
				auto index = BookStore::createScene(P_TRAIN_2);
				director->replaceScene(index);
			});

			CCSequence *seq = CCSequence::create(sp1, sp2, sp3, sp4, sp5, sp6, CCDelayTime::create(0.3), callFunc, CCDelayTime::create(0.8), callFunc2, NULL);
			scoUp->runAction(seq);
		});
		scoUp->setTag(88);
		auto scoDown = (ui::ImageView*)bookNode2->getChildByName(BABYCENTER_FIND_YILAPAIHANG);
		scoDown->setTouchEnabled(true);
		scoDown->setSwallowTouches(false);
		scoDown->addClickEventListener([=](Ref* sender)
		{
			CCScaleTo* sc1 = CCScaleTo::create(0.3, 1.25);
			CCRotateTo* ro1 = CCRotateTo::create(0.3, 10);
			CCSpawn* sp1 = CCSpawn::create(sc1, ro1, NULL);

			CCScaleTo* sc2 = CCScaleTo::create(0.1, 1.2);
			CCRotateTo* ro2 = CCRotateTo::create(0.1, -8);
			CCSpawn* sp2 = CCSpawn::create(sc2, ro2, NULL);

			CCScaleTo* sc3 = CCScaleTo::create(0.1, 1.15);
			CCRotateTo* ro3 = CCRotateTo::create(0.1, 6);
			CCSpawn* sp3 = CCSpawn::create(sc3, ro3, NULL);

			CCScaleTo* sc4 = CCScaleTo::create(0.15, 1.1);
			CCRotateTo* ro4 = CCRotateTo::create(0.15, -4);
			CCSpawn* sp4 = CCSpawn::create(sc4, ro4, NULL);

			CCScaleTo* sc5 = CCScaleTo::create(0.1, 1.1);
			CCRotateTo* ro5 = CCRotateTo::create(0.1, 2);
			CCSpawn* sp5 = CCSpawn::create(sc5, ro5, NULL);

			CCScaleTo* sc6 = CCScaleTo::create(0.25, 1);
			CCRotateTo* ro6 = CCRotateTo::create(0.25, 0);
			CCSpawn* sp6 = CCSpawn::create(sc6, ro6, NULL);

			CCCallFunc *callFunc = CCCallFunc::create([=]() {

				_scrollView->runAction(MoveBy::create(0.8f, Point(0, 1430)));
				backWall->runAction(MoveBy::create(0.8f, Point(0, 1430)));
				floor->runAction(MoveBy::create(1.2f, Point(0, -320)));
				leftColumn->runAction(MoveBy::create(1.2f, Point(-200, 0)));
				rightColumn->runAction(MoveBy::create(1.2f, Point(200, 0)));
			});

			CCCallFunc *callFunc2 = CCCallFunc::create([=]() {
				auto director = Director::getInstance();
				auto index = BookStore::createScene(P_TRAIN_2);
				director->replaceScene(index);
			});

			CCSequence *seq = CCSequence::create(sp1, sp2, sp3, sp4, sp5, sp6, CCDelayTime::create(0.3), callFunc, CCDelayTime::create(0.8), callFunc2, NULL);
			scoDown->runAction(seq);
		});
		scoDown->setTag(99);
		vecAll.pushBack(bookNode2);  
	}
    
	int count = -1;
    Node* temp;  
    for (int i = 0; i < vecAll.size(); i++)
    {
		
        temp = vecAll.at(i);
        if (temp->getTag()==BOOK_STORE_BORDER_BIG)
        {
			count++;
          temp->setPosition(Vec2(i * 620 + 530, 550));
		  
        }
        else if (temp->getTag()==BOOK_STORE_BORDER_SMALL)
        {  
            temp->setPosition(Vec2(i * 530 + 530, 0));
			
        }
        _scrollView->addChild(temp);
		_scrollView->setTag(999);
    }

	ImageView* upBook;
	ImageView* DownBook;
	
	//upBook = (ui::ImageView*)ui::Helper::seekWidgetByTag(_scrollView, 88);
	
	auto sco4 = (ui::ImageView*)bookNode1->getChildByName(BABYCENTER_FIND_YILATUIJIAN);
	sco4->setTouchEnabled(true);
	sco4->setSwallowTouches(false);
	sco4->addClickEventListener([=](Ref* sender)
	{
		CCScaleTo* sc1 = CCScaleTo::create(0.3, 1.25);
		CCRotateTo* ro1 = CCRotateTo::create(0.3, 10);
		CCSpawn* sp1 = CCSpawn::create(sc1,ro1,NULL);

		CCScaleTo* sc2 = CCScaleTo::create(0.1, 1.2);
		CCRotateTo* ro2 = CCRotateTo::create(0.1, -8);
		CCSpawn* sp2 = CCSpawn::create(sc2, ro2, NULL);

		CCScaleTo* sc3 = CCScaleTo::create(0.1, 1.15);
		CCRotateTo* ro3 = CCRotateTo::create(0.1, 6);
		CCSpawn* sp3 = CCSpawn::create(sc3, ro3, NULL);

		CCScaleTo* sc4 = CCScaleTo::create(0.15, 1.1);
		CCRotateTo* ro4 = CCRotateTo::create(0.15, -4);
		CCSpawn* sp4 = CCSpawn::create(sc4, ro4, NULL);

		CCScaleTo* sc5 = CCScaleTo::create(0.1, 1.1);
		CCRotateTo* ro5 = CCRotateTo::create(0.1, 2);
		CCSpawn* sp5 = CCSpawn::create(sc5, ro5, NULL);

		CCScaleTo* sc6 = CCScaleTo::create(0.25, 1);
		CCRotateTo* ro6 = CCRotateTo::create(0.25, 0);
		CCSpawn* sp6 = CCSpawn::create(sc6, ro6, NULL);

		CCCallFunc *callFunc = CCCallFunc::create([=]() {

			_scrollView->runAction(MoveBy::create(0.8f, Point(0, 1430)));
			backWall->runAction(MoveBy::create(0.8f, Point(0, 1430)));
			floor->runAction(MoveBy::create(1.2f, Point(0, -320)));
			leftColumn->runAction(MoveBy::create(1.2f, Point(-200, 0)));
			rightColumn->runAction(MoveBy::create(1.2f, Point(200, 0)));
		});

		CCCallFunc *callFunc2 = CCCallFunc::create([=]() {
			auto director = Director::getInstance();
			auto index = BookStore::createScene(P_TRAIN_2);
			director->replaceScene(index);
		});

		CCSequence *seq = CCSequence::create(sp1, sp2, sp3, sp4, sp5, sp6, CCDelayTime::create(0.3), callFunc, CCDelayTime::create(0.8),callFunc2,NULL);
		sco4->runAction(seq);
	});

/*
	auto listview = ListView::create();
	listview->setDirection(ScrollView::Direction::HORIZONTAL);
	listview->setSize(Size(2736, 1500));
	//listview->setPosition(Vec2(origin.x, origin.y));
	listview->setPosition(Vec2(0, 0));
	listview->setGravity(ListView::Gravity::BOTTOM);
	listview->setTouchEnabled(true);
	listview->setBounceEnabled(true);
	listview->setScrollBarEnabled(true);
	listview->setSwallowTouches(false);
	addChild(listview);

	//推荐
	//Vector<ListView*> vec;
	listview->pushBackCustomItem(createItem(BABYCENTER_TUIJIANLAYER_CSB, Vec2(280, 350), Size(782, 982)));
	
	CCSize cellSize = CCSizeMake(480, 1220);


	Vector<Node*> m_books;
	for (int i = 0; i < allCount; i++)
	{
		auto bookNode = (Node*)CSLoader::createNode(BABYCENTER_PAIHANGLAYER_CSB);
		//m_books.pushBack(bookNode);
		bookNode->setPosition(Vec2((i) * 40, 280));
		auto layoutnode1 = Layout::create();
		layoutnode1->setSize(cellSize);
		layoutnode1->addChild(bookNode);
		listview->pushBackCustomItem(layoutnode1);
	}
	
	for (int i = 0; i < allCount; i++)
	{
		if (i % 2 == 0)
		{
			m_books.at(i)->setPosition(Vec2((i + 1) * 280 + 50, 850));
		}
		else
		{
			m_books.at(i)->setPosition(Vec2(i * 280 + 50, 300));
		}
	}
	

	listview->addEventListenerListView(this, SEL_ListViewEvent(&BookCityScene::selectedItemEvent));
	addChild(listview);
*/

	//返回按钮
	auto homeButton = (ui::Button*)node->getChildByName(BABYCENTER_FIND_BACK);
	homeButton->setTouchEnabled(true);
	homeButton->addClickEventListener([](Ref* sender) {
		CCLOG("点击返回");
		Index::GoToIndexScene();
		auto director = Director::getInstance();
		auto index = Index::createScene();
		director->replaceScene(index);
	});
	
	return true;
}
Example #29
0
int
DomainPartitioner::partition(int numParts, bool usingMain, int mainPartitionTag, int specialElementTag)
{

  usingMainDomain = usingMain;
  mainPartition = mainPartitionTag;

  // first we ensure the partitioned domain has numpart subdomains
  // with tags 1 through numparts
  for (int i=1; i<=numParts; i++) {
    if (i != mainPartition) {
      Subdomain *subdomainPtr = myDomain->getSubdomainPtr(i);
      if (subdomainPtr == 0) {
	opserr << "DomainPartitioner::partition - No Subdomain: ";
	opserr << i << " exists\n";
	return -1;
      }
    }
  }

  // we get the ele graph from the domain and partition it
  //    Graph &theEleGraph = myDomain->getElementGraph();
  //    theElementGraph = new Graph(myDomain->getElementGraph());

  theElementGraph = &(myDomain->getElementGraph());

  int theError = thePartitioner.partition(*theElementGraph, numParts);

  if (theError < 0) {
    opserr << "DomainPartitioner::partition";
    opserr << " - the graph partioner failed to partition the ";
    opserr << "element graph\n";
    return -10+theError;
  }

  /* print graph */
  //  opserr << "DomainPartitioner::partition - eleGraph: \n";
  //  theElementGraph->Print(opserr, 4);
  
  VertexIter &theVertices1 = theElementGraph->getVertices();
  Vertex *vertexPtr = 0;
  bool moreThanOne = false;
  
  vertexPtr = theVertices1();
  int vertexOnePartition  = 0;
  if (vertexPtr != 0)
    vertexOnePartition  = vertexPtr->getColor();  
  while ((moreThanOne == false) && ((vertexPtr = theVertices1()) != 0)) {
    int partition = vertexPtr->getColor();
    if (partition != vertexOnePartition ) {
      moreThanOne = true;
    }
  }

  if (moreThanOne == false) {
    opserr <<"DomainPartitioner::partition - too few elements for model to be partitioned\n";
    return -1;
  }

  int specialElementColor = 1;
  if (specialElementTag != 0) {
    bool found = false;
    VertexIter &theVerticesSpecial = theElementGraph->getVertices();
    while ((found == false) && ((vertexPtr = theVerticesSpecial()) != 0)) {
      int eleTag = vertexPtr->getRef();
      if (eleTag == specialElementTag) {
	found = true;
	int vertexColor = vertexPtr->getColor();
	if (vertexColor != 1)
	  //	  specialElementColor = vertexColor;
	  vertexPtr->setColor(1);
      }
    }
  }
  
      
  // we create empty graphs for the numParts subdomains,
  // in the graphs we place the vertices for the elements on the boundaries
  
  // we do not invoke the destructor on the individual graphs as 
  // this would invoke the destructor on the individual vertices

  if (theBoundaryElements != 0)
    delete [] theBoundaryElements;
  
  theBoundaryElements = new Graph * [numParts];
  if (theBoundaryElements == 0) {
    opserr << "DomainPartitioner::partition(int numParts)";
    opserr << " - ran out of memory\n";
    numPartitions = 0;  
    return -1;
  }

  for (int l=0; l<numParts; l++) {
    theBoundaryElements[l] = new Graph(2048); // graphs can grow larger; just an estimate
    
    if (theBoundaryElements[l] == 0) {
      opserr << "DomainPartitioner::partition(int numParts)";
      opserr << " - ran out of memory\n";
      numPartitions = 0;
      return -1;
    }
  }
  
  numPartitions = numParts;

  //  opserr << "DomainPartitioner::partition() - nodes \n";  
  
  // we now create a MapOfTaggedObjectStorage to store the NodeLocations
  // and create a new NodeLocation for each node; adding it to the map object

  theNodeLocations = new MapOfTaggedObjects();
  if (theNodeLocations == 0) {
    opserr << "DomainPartitioner::partition(int numParts)";
    opserr << " - ran out of memory creating MapOfTaggedObjectStorage for node locations\n";
    numPartitions = 0;
    return -1;
  }

  NodeIter &theNodes = myDomain->getNodes();
  Node *nodePtr;
  while ((nodePtr = theNodes()) != 0) {
    NodeLocations *theNodeLocation = new NodeLocations(nodePtr->getTag());
    if (theNodeLocation == 0) {
      opserr << "DomainPartitioner::partition(int numParts)";
      opserr << " - ran out of memory creating NodeLocation for node: " << nodePtr->getTag() << endln;
      numPartitions = 0;
      return -1;
    }
    if (theNodeLocations->addComponent(theNodeLocation) == false) {
      opserr << "DomainPartitioner::partition(int numParts)";
      opserr << " - failed to add NodeLocation to Map for Node: " << nodePtr->getTag() << endln;
      numPartitions = 0;
      return -1;
    }
  }

  //
  // we now iterate through the vertices of the element graph
  // to see if the vertex is a boundary vertex or not - if it is
  // we add to the appropriate graph created above. We also set the
  // value the color variable of each of the external nodes connected 
  // to the element to a value which will indicate that that node will
  // have to be added to the subdomain.
  //
  
  VertexIter &theVertexIter = theElementGraph->getVertices();
  while ((vertexPtr = theVertexIter()) != 0) {
    int eleTag = vertexPtr->getRef();
    int vertexColor = vertexPtr->getColor();
    
    const ID &adjacency = vertexPtr->getAdjacency();
    int size = adjacency.Size();
    for (int i=0; i<size; i++) {
      Vertex *otherVertex = theElementGraph->getVertexPtr(adjacency(i));
      if (otherVertex->getColor() != vertexColor) {
	theBoundaryElements[vertexColor-1]->addVertex(vertexPtr,false);
	i = size;
      }
    }
    
    Element *elePtr = myDomain->getElement(eleTag);
    const ID &nodes = elePtr->getExternalNodes();
    size = nodes.Size();
    for (int j=0; j<size; j++) {
      int nodeTag = nodes(j);
      TaggedObject *theTaggedObject = theNodeLocations->getComponentPtr(nodeTag);
      if (theTaggedObject == 0) {
	opserr << "DomainPartitioner::partition(int numParts)";
	opserr << " - failed to find NodeLocation in Map for Node: " << nodePtr->getTag() << " -- A BUG!!\n";
	numPartitions = 0;
	return -1;	
      }
      NodeLocations *theNodeLocation = (NodeLocations *)theTaggedObject;
      theNodeLocation->addPartition(vertexColor);
    }
  }

  // now go through the MP_Constraints and ensure the retained node is in every 
  // partition the constrained node is in
  MP_ConstraintIter &theMPs = myDomain->getMPs();
  MP_Constraint *mpPtr;
  while ((mpPtr = theMPs()) != 0) {
    int retained = mpPtr->getNodeRetained();
    int constrained = mpPtr->getNodeConstrained();
    
    TaggedObject *theRetainedObject = theNodeLocations->getComponentPtr(retained);      
    TaggedObject *theConstrainedObject = theNodeLocations->getComponentPtr(constrained);
    
    if (theRetainedObject == 0 || theConstrainedObject == 0) {
      opserr << "DomainPartitioner::partition(int numParts)";
      if (theRetainedObject == 0)
	opserr << " - failed to find NodeLocation in Map for Node: " << retained << " -- A BUG!!\n";
      if (theConstrainedObject == 0)
	opserr << " - failed to find NodeLocation in Map for Node: " << constrained << " -- A BUG!!\n";
      numPartitions = 0;
      return -1;	
    }
    
    NodeLocations *theRetainedLocation = (NodeLocations *)theRetainedObject;
    NodeLocations *theConstrainedLocation = (NodeLocations *)theConstrainedObject;
    ID &theConstrainedNodesPartitions = theConstrainedLocation->nodePartitions;
    int numPartitions = theConstrainedNodesPartitions.Size();
    for (int i=0; i<numPartitions; i++) {
      theRetainedLocation->addPartition(theConstrainedNodesPartitions(i));
    }
  }

  // we now add the nodes, 
  TaggedObjectIter &theNodeLocationIter = theNodeLocations->getComponents();
  TaggedObject *theNodeObject;

  while ((theNodeObject = theNodeLocationIter()) != 0) {
    NodeLocations *theNodeLocation = (NodeLocations *)theNodeObject;

    int nodeTag = theNodeLocation->getTag();
    ID &nodePartitions = theNodeLocation->nodePartitions;
    int numPartitions = theNodeLocation->numPartitions;

    for (int i=0; i<numPartitions; i++) {
      int partition = nodePartitions(i);	  
      if (partition != mainPartition) {      
	Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition); 
	if (numPartitions == 1) {
	  Node *nodePtr = myDomain->removeNode(nodeTag);
	  theSubdomain->addNode(nodePtr);
	} else {
	  Node *nodePtr = myDomain->getNode(nodeTag);
	  theSubdomain->addExternalNode(nodePtr);	  
	}
      }
    }
  }

  // we now move the elements 
  VertexIter &theVertices = theElementGraph->getVertices();
  while ((vertexPtr = theVertices()) != 0) {
    // move the element
    int partition = vertexPtr->getColor();
    if (partition != mainPartition) {          
      int eleTag = vertexPtr->getRef();

      //      opserr << "removing ele: " << eleTag << endln;
      
      Element *elePtr = myDomain->removeElement(eleTag);  
      //      opserr << *elePtr;

      if (elePtr != 0) {
	//	opserr << "adding ele - start\n";
	Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition);  
	theSubdomain->addElement(elePtr);

	//	opserr << "adding ele - done\n";
      } else {
	opserr << "DomainPartitioner::partioner - element GONE! - eleTag " << eleTag << endln;
      }
    } 
  }

  // now we go through the load patterns and move NodalLoad
  // 1) make sure each subdomain has a copy of the partitioneddomains load patterns.
  // 2) move nodal loads
  // 3) move SP_Constraints
  
  LoadPatternIter &theLoadPatterns = myDomain->getLoadPatterns();
  LoadPattern *theLoadPattern;
  while ((theLoadPattern = theLoadPatterns()) != 0) {
    int loadPatternTag = theLoadPattern->getTag();

    
    // check that each subdomain has a loadPattern with a similar tag and class tag
    for (int i=1; i<=numParts; i++) {
      if (i != mainPartition) {
	Subdomain *theSubdomain = myDomain->getSubdomainPtr(i);
	LoadPattern *loadPatternCopy = theSubdomain->getLoadPattern(loadPatternTag);
	if (loadPatternCopy == 0) {
	  LoadPattern *newLoadPattern = theLoadPattern->getCopy();
	  if (newLoadPattern == 0) {
	    opserr << "DomaiPartitioner::partition - out of memory creating LoadPatterns\n";
 	    return -1;
	  }
	  theSubdomain->addLoadPattern(newLoadPattern);
	}
      }
    }

    // now remove any nodal loads that correspond to internal nodes in a subdomain
    // and add them to the appropriate loadpattern in the subdomain
    
    NodalLoadIter &theNodalLoads = theLoadPattern->getNodalLoads();
    NodalLoad *theNodalLoad;
    while ((theNodalLoad = theNodalLoads()) != 0) {
      int nodeTag = theNodalLoad->getNodeTag();

      TaggedObject *theTaggedObject = theNodeLocations->getComponentPtr(nodeTag);
      if (theTaggedObject == 0) {
	opserr << "DomainPartitioner::partition(int numParts)";
	opserr << " - failed to find NodeLocation in Map for Node: " << nodeTag << " -- A BUG!!\n";
	numPartitions = 0;
	return -1;	
      }
    
      NodeLocations *theNodeLocation = (NodeLocations *)theTaggedObject;
      ID &nodePartitions = theNodeLocation->nodePartitions;
      int numPartitions = theNodeLocation->numPartitions;
      for (int i=0; i<numPartitions; i++) {
	int partition = nodePartitions(i);	  
	if (partition != mainPartition) {      
	  if (numPartitions == 1) {
	    Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition);
	    theLoadPattern->removeNodalLoad(theNodalLoad->getTag());
	    if ((theSubdomain->addNodalLoad(theNodalLoad, loadPatternTag)) != true)
	      opserr << "DomainPartitioner::partition() - failed to add Nodal Load\n";
	  }
	}
      }      
    }

  
    SP_ConstraintIter &theSPs = theLoadPattern->getSPs();
    SP_Constraint *spPtr;
    while ((spPtr = theSPs()) != 0) {
      int nodeTag = spPtr->getNodeTag();
      
      TaggedObject *theTaggedObject = theNodeLocations->getComponentPtr(nodeTag);
      if (theTaggedObject == 0) {
	opserr << "DomainPartitioner::partition(int numParts)";
	opserr << " - failed to find NodeLocation in Map for Node: " << nodeTag << " -- A BUG!!\n";
	numPartitions = 0;
	return -1;	
      }
      
      NodeLocations *theNodeLocation = (NodeLocations *)theTaggedObject;
      ID &nodePartitions = theNodeLocation->nodePartitions;
      int numPartitions = theNodeLocation->numPartitions;
      for (int i=0; i<numPartitions; i++) {
	int partition = nodePartitions(i);	  
	if (partition != mainPartition) {      
	  Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition); 
	  if (numPartitions == 1) 
	    theLoadPattern->removeSP_Constraint(spPtr->getTag());
	  int res = theSubdomain->addSP_Constraint(spPtr, loadPatternTag);
	  if (res < 0)
	    opserr << "DomainPartitioner::partition() - failed to add SP Constraint\n";
	}
      }    
    }  

    ElementalLoadIter &theLoads = theLoadPattern->getElementalLoads();
    ElementalLoad *theLoad;
    while ((theLoad = theLoads()) != 0) {
      int loadEleTag = theLoad->getElementTag();

      SubdomainIter &theSubdomains = myDomain->getSubdomains();
      Subdomain *theSub;
      bool added = false;
      while (((theSub = theSubdomains()) != 0) && (added == false)) {
	bool res = theSub->hasElement(loadEleTag);
	if (res == true) {
	  theLoadPattern->removeElementalLoad(theLoad->getTag());
	  theSub->addElementalLoad(theLoad, loadPatternTag);
	  if (res < 0)
	    opserr << "DomainPartitioner::partition() - failed to add ElementalLoad\n";
	  added = true;
	}
      }   
    }
  }

  // add the single point constraints, 
  
  SP_ConstraintIter &theDomainSP = myDomain->getSPs();
  SP_Constraint *spPtr;
  while ((spPtr = theDomainSP()) != 0) {
    int nodeTag = spPtr->getNodeTag();

    TaggedObject *theTaggedObject = theNodeLocations->getComponentPtr(nodeTag);
    if (theTaggedObject == 0) {
      opserr << "DomainPartitioner::partition(int numParts)";
      opserr << " - failed to find NodeLocation in Map for Node: " << nodeTag << " -- A BUG!!\n";
      numPartitions = 0;
      return -1;	
    }
    
    NodeLocations *theNodeLocation = (NodeLocations *)theTaggedObject;
    ID &nodePartitions = theNodeLocation->nodePartitions;
    int numPartitions = theNodeLocation->numPartitions;
    for (int i=0; i<numPartitions; i++) {
      int partition = nodePartitions(i);	  

      if (partition != mainPartition) {      
	Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition); 
	if (numPartitions == 1) {
	  myDomain->removeSP_Constraint(spPtr->getTag());
	}
	int res = theSubdomain->addSP_Constraint(spPtr);
	if (res < 0)
	  opserr << "DomainPartitioner::partition() - failed to add SP Constraint\n";
      }
    }    
  }  

  // move MP_Constraints - add an MP_Constraint to every partition a constrained node is in
  MP_ConstraintIter &moreMPs = myDomain->getMPs();
  while ((mpPtr = moreMPs()) != 0) {
    int constrained = mpPtr->getNodeConstrained();
    TaggedObject *theConstrainedObject = theNodeLocations->getComponentPtr(constrained);
    NodeLocations *theConstrainedLocation = (NodeLocations *)theConstrainedObject;
    ID &theConstrainedNodesPartitions = theConstrainedLocation->nodePartitions;
    int numPartitions = theConstrainedLocation->numPartitions;
    for (int i=0; i<numPartitions; i++) {
      int partition = theConstrainedNodesPartitions(i);
      if (partition != mainPartition) {
	Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition);
	if (numPartitions == 1) 
	  myDomain->removeMP_Constraint(mpPtr->getTag());
	int res = theSubdomain->addMP_Constraint(mpPtr);
	if (res < 0)
	  opserr << "DomainPartitioner::partition() - failed to add MP Constraint\n";
      }
    }
  }

  // now we go through all the subdomains and tell them to update
  // their analysis for the new layouts
  
  SubdomainIter &theSubDomains = myDomain->getSubdomains();
  Subdomain *theSubDomain;
  while ((theSubDomain = theSubDomains()) != 0) 
    theSubDomain->domainChange();
  
  // we invoke change on the PartitionedDomain
  myDomain->domainChange();

  myDomain->clearElementGraph();
    
  // we are done
  partitionFlag = true;

  return 0;
}
int
TransformationConstraintHandler::handle(const ID *nodesLast)
{
    // first check links exist to a Domain and an AnalysisModel object
    Domain *theDomain = this->getDomainPtr();
    AnalysisModel *theModel = this->getAnalysisModelPtr();
    Integrator *theIntegrator = this->getIntegratorPtr();    
    
    if ((theDomain == 0) || (theModel == 0) || (theIntegrator == 0)) {
	opserr << "WARNING TransformationConstraintHandler::handle() - ";
	opserr << " setLinks() has not been called\n";
	return -1;
    }
    
    // get number ofelements and nodes in the domain 
    // and init the theFEs and theDOFs arrays
    int numMPConstraints = theDomain->getNumMPs();

    //    int numSPConstraints = theDomain->getNumSPs();    
    int numSPConstraints = 0;
    SP_ConstraintIter &theSP1s = theDomain->getDomainAndLoadPatternSPs();
    SP_Constraint *theSP1; 
    while ((theSP1 = theSP1s()) != 0) 
	numSPConstraints++;
    
    numDOF = 0;
    ID transformedNode(0, 64);

    int i;
    
    // create an ID of constrained node tags in MP_Constraints
    ID constrainedNodesMP(0, numMPConstraints);
    MP_Constraint **mps =0;
    if (numMPConstraints != 0) {
	mps = new MP_Constraint *[numMPConstraints];
	if (mps == 0) {
	    opserr << "WARNING TransformationConstraintHandler::handle() - ";
	    opserr << "ran out of memory for MP_Constraints"; 
	    opserr << " array of size " << numMPConstraints << endln;
	    return -3;	    
	}
	MP_ConstraintIter &theMPs = theDomain->getMPs();
	MP_Constraint *theMP; 
	int index = 0;
	while ((theMP = theMPs()) != 0) {
	  int nodeConstrained = theMP->getNodeConstrained();
	  if (transformedNode.getLocation(nodeConstrained) < 0)
	    transformedNode[numDOF++] = nodeConstrained;
	  constrainedNodesMP[index] = nodeConstrained;
	  mps[index] = theMP;
	  index++;
	}	
    }

    // create an ID of constrained node tags in SP_Constraints
    ID constrainedNodesSP(0, numSPConstraints);;
    SP_Constraint **sps =0;
    if (numSPConstraints != 0) {
	sps = new SP_Constraint *[numSPConstraints];
	if (sps == 0) {
	    opserr << "WARNING TransformationConstraintHandler::handle() - ";
	    opserr << "ran out of memory for SP_Constraints"; 
	    opserr << " array of size " << numSPConstraints << endln;
	    if (mps != 0) delete [] mps;
	    if (sps != 0) delete [] sps;
	    return -3;	    
	}
	SP_ConstraintIter &theSPs = theDomain->getDomainAndLoadPatternSPs();
	SP_Constraint *theSP; 
	int index = 0;
	while ((theSP = theSPs()) != 0) {
	  int constrainedNode = theSP->getNodeTag();
	  if (transformedNode.getLocation(constrainedNode) < 0)
	    transformedNode[numDOF++] = constrainedNode;	    
	  constrainedNodesSP[index] = constrainedNode;
	  sps[index] = theSP;
	  index++;
	}	
    }

    // create an array for the DOF_Groups and zero it
    if ((numDOF != 0) && ((theDOFs = new DOF_Group *[numDOF]) == 0)) {
	opserr << "WARNING TransformationConstraintHandler::handle() - ";
        opserr << "ran out of memory for DOF_Groups";
	opserr << " array of size " << numDOF << endln;
	return -3;    
    }    
    for (i=0; i<numDOF; i++) theDOFs[i] = 0;

    //create a DOF_Group for each Node and add it to the AnalysisModel.
    //    :must of course set the initial IDs
    NodeIter &theNod = theDomain->getNodes();
    Node *nodPtr;

    int numDofGrp = 0;
    int count3 = 0;
    int countDOF =0;
    
    numConstrainedNodes = 0;
    numDOF = 0;
    while ((nodPtr = theNod()) != 0) {

        DOF_Group *dofPtr = 0;

	int nodeTag = nodPtr->getTag();
	int numNodalDOF = nodPtr->getNumberDOF();
	int loc = -1;
	int createdDOF = 0;

	loc = constrainedNodesMP.getLocation(nodeTag);
	if (loc >= 0) {

	  TransformationDOF_Group *tDofPtr = 
	    new TransformationDOF_Group(numDofGrp++, nodPtr, mps[loc], this); 

	  createdDOF = 1;
	  dofPtr = tDofPtr;
	  
	  // add any SPs
	  if (numSPConstraints != 0) {
	    loc = constrainedNodesSP.getLocation(nodeTag);
	    if (loc >= 0) {
	      tDofPtr->addSP_Constraint(*(sps[loc]));
	      for (int i = loc+1; i<numSPConstraints; i++) {
		if (constrainedNodesSP(i) == nodeTag)
		  tDofPtr->addSP_Constraint(*(sps[i]));
	      }
	    }
	    // add the DOF to the array	    
	    theDOFs[numDOF++] = dofPtr;	    	    
	    numConstrainedNodes++;
	  }
	}
	
	if (createdDOF == 0) {
	  loc = constrainedNodesSP.getLocation(nodeTag);
	  if (loc >= 0) {
	    TransformationDOF_Group *tDofPtr = 
	      new TransformationDOF_Group(numDofGrp++, nodPtr, this);

	    int numSPs = 1;
	    createdDOF = 1;
	    dofPtr = tDofPtr;
	    tDofPtr->addSP_Constraint(*(sps[loc]));
	
	    // check for more SP_constraints acting on node and add them
	    for (int i = loc+1; i<numSPConstraints; i++) {
	      if (constrainedNodesSP(i) == nodeTag) {
		tDofPtr->addSP_Constraint(*(sps[i]));
		numSPs++;
	      }
	    }
	    // add the DOF to the array
	    theDOFs[numDOF++] = dofPtr;	    	    
	    numConstrainedNodes++;	    
	    countDOF+= numNodalDOF - numSPs;		
	  }
	}

	// create an ordinary DOF_Group object if no dof constrained
	if (createdDOF == 0) {
	    if ((dofPtr = new DOF_Group(numDofGrp++, nodPtr)) == 0) {
		opserr << "WARNING TransformationConstraintHandler::handle() ";
		opserr << "- ran out of memory";
		opserr << " creating DOF_Group " << i << endln;	
		if (mps != 0) delete [] mps;
		if (sps != 0) delete [] sps;
		return -4;    		
	    }
	
	    countDOF+= numNodalDOF;
	}
	
	if (dofPtr == 0) 
	  opserr << "TransformationConstraintHandler::handle() - error in logic\n";
	    
	nodPtr->setDOF_GroupPtr(dofPtr);
	theModel->addDOF_Group(dofPtr);
    }

    // create the FE_Elements for the Elements and add to the AnalysisModel
    ElementIter &theEle = theDomain->getElements();
    Element *elePtr;
    FE_Element *fePtr;

    numFE = 0;
    ID transformedEle(0, 64);

    while ((elePtr = theEle()) != 0) {
      int flag = 0;
      if (elePtr->isSubdomain() == true) {
	Subdomain *theSub = (Subdomain *)elePtr;
	if (theSub->doesIndependentAnalysis() == true) 
	  flag = 1;
      }

      if (flag == 0) {
      
	const ID &nodes = elePtr->getExternalNodes();
	int nodesSize = nodes.Size();
	int isConstrainedNode = 0;
	for (int i=0; i<nodesSize; i++) {
	  int nodeTag = nodes(i);
	  if (numMPConstraints != 0) {
	    int loc = constrainedNodesMP.getLocation(nodeTag);
	    if (loc >= 0) {
	      isConstrainedNode = 1;
	      i = nodesSize;
	    }
	  } 
	  if (numSPConstraints != 0 && isConstrainedNode == 0) {
	    int loc = constrainedNodesSP.getLocation(nodeTag);
	    if (loc >= 0) {
	      isConstrainedNode = 1;		    
	      i = nodesSize;
	    }
	  }
	}
	
	if (isConstrainedNode == 1) {
	  transformedEle[numFE++] = elePtr->getTag();
	}
      }
    }
    
    // create an array for the FE_elements and zero it
    if ((numFE != 0) && ((theFEs  = new FE_Element *[numFE]) == 0)) {
      opserr << "WARNING TransformationConstraintHandler::handle() - ";
      opserr << "ran out of memory for FE_elements"; 
      opserr << " array of size " << numFE << endln;
      return -2;
    }
    
    for (i=0; i<numFE; i++) theFEs[i] = 0;

    ElementIter &theEle1 = theDomain->getElements();
    
    // int numConstraints = numMPConstraints+numSPConstraints;
    int numFeEle = 0;
    int numFE = 0;

    while ((elePtr = theEle1()) != 0) {
      int tag = elePtr->getTag();
      if (elePtr->isSubdomain() == true) {
	Subdomain *theSub = (Subdomain *)elePtr;
	if (theSub->doesIndependentAnalysis() == false) {
	  
	  if (transformedEle.getLocation(tag) < 0) {
	    if ((fePtr = new FE_Element(numFeEle, elePtr)) == 0) {
	      opserr << "WARNING TransformationConstraintHandler::handle()";
	      opserr << " - ran out of memory";
	      opserr << " creating FE_Element " << elePtr->getTag() << endln; 
	      if (mps != 0) delete [] mps;
	      if (sps != 0) delete [] sps;
	      return -5;
	    }	
	  } else {
	    if ((fePtr = new TransformationFE(numFeEle, elePtr)) == 0) {		
	      opserr << "WARNING TransformationConstraintHandler::handle()";
	      opserr << " - ran out of memory";
	      opserr << " creating TransformationFE " << elePtr->getTag() << endln; 
	      if (mps != 0) delete [] mps;
	      if (sps != 0) delete [] sps;
	      return -6;		    
	    }
	    theFEs[numFE++] = fePtr;
	  }

	  numFeEle++;
	  theModel->addFE_Element(fePtr);
	  theSub->setFE_ElementPtr(fePtr);
	}
      } else {
	if (transformedEle.getLocation(tag) < 0) {
	  if ((fePtr = new FE_Element(numFeEle, elePtr)) == 0) {
	    opserr << "WARNING TransformationConstraintHandler::handle()";
	    opserr << " - ran out of memory";
	    opserr << " creating FE_Element " << elePtr->getTag() << endln; 
	    if (mps != 0) delete [] mps;
	    if (sps != 0) delete [] sps;
	    return -5;
	  }	
	} else {
	  if ((fePtr = new TransformationFE(numFeEle, elePtr)) == 0) {		
	    opserr << "WARNING TransformationConstraintHandler::handle()";
	    opserr << " - ran out of memory";
	    opserr << " creating TransformationFE " << elePtr->getTag() << endln; 
	    if (mps != 0) delete [] mps;
	    if (sps != 0) delete [] sps;
	    return -6;		    
	  }
	  theFEs[numFE++] = fePtr;
	}
	
	numFeEle++;
	theModel->addFE_Element(fePtr);
      }
    }

    theModel->setNumEqn(countDOF);
    
    // set the number of eqn in the model
    // now see if we have to set any of the dof's to -3
    //    int numLast = 0;
    if (nodesLast != 0) 
	for (i=0; i<nodesLast->Size(); i++) {
	    int nodeID = (*nodesLast)(i);
	    Node *nodPtr = theDomain->getNode(nodeID);
	    if (nodPtr != 0) {
		DOF_Group *dofPtr = nodPtr->getDOF_GroupPtr();
		
		const ID &id = dofPtr->getID();
		// set all the dof values to -3
		for (int j=0; j < id.Size(); j++) {
		    if (id(j) == -2) {
			dofPtr->setID(j,-3);
			count3++;
		    } else {
			opserr << "WARNING TransformationConstraintHandler::handle() ";
			opserr << " - boundary sp constraint in subdomain";
			opserr << " this should not be - results suspect \n";
			if (mps != 0) delete [] mps;
			if (sps != 0) delete [] sps;
		    }
		}
	    }
	}

    if (mps != 0) delete [] mps;
    if (sps != 0) delete [] sps;

    return count3;
}