bool CBlastXMLParse::_Parse(TiXmlDocument& TinyXML) { TiXmlElement* tiRoot = TinyXML.RootElement(); if (!tiRoot) { return false; } std::string sRootName = tiRoot->Value(); if (sRootName != BLAST_ROOT_GAME) { return false; } TiXmlNode* tiFirst = tiRoot->FirstChild(BLAST_GAME); if (tiFirst == NULL) { return false; } for (TiXmlElement* tiElement = tiFirst->ToElement(); tiElement != NULL; tiElement = tiElement->NextSiblingElement()) { CBlastXMLObject* pBlast = new CBlastXMLObject; std::string strSkinId; int nFrameCount = 0; if (!BaseParse(pBlast, tiElement)) { continue; } Unit::GetXmlStrAttributeA(tiElement ,PLANE_SKIN_OBJECT, strSkinId); Unit::GetXmlIntAttribute(tiElement ,FRAMECOUNT_OBJECT, nFrameCount); pBlast->SetSkinId(strSkinId); pBlast->SetFrameCount(nFrameCount); ShapeObject shapeobj; BaseShape(&shapeobj, tiElement); pBlast->SetWidth(shapeobj.nWidth); pBlast->SetHeight(shapeobj.nHeight); m_mapBlast[pBlast->GetId()] = pBlast; } return true; }
void ModelTest() { int array[4][4]={1}; int i,j; try { BaseShape bs1(1); if (bs1.get_color()==0) throw int(2); BaseShape bs2(2); if (bs2.get_color()!=2) throw int(2); BaseShape bs3(bs1); if (ShapeEqual(bs1,bs3)) throw int(2); if (!ShapeEqual(bs2,bs3)) throw int(2); if (ShapeEqual(bs3,BaseShape(bs1))) throw int(2); if (!ShapeEqual(bs3,BaseShape(bs2))) throw int(2); BaseShape bs4=bs1; if (ShapeEqual(bs1,bs4)) throw int(2); if (!ShapeEqual(bs2,bs4)) throw int(2); BaseShape bs5=BaseShape(bs2); if (ShapeEqual(bs2,bs5)) throw int(2); if (!ShapeEqual(bs1,bs5)) throw int(2); BaseShape s(0); s.set_x(1); if (s.get_x()!=1) throw int(2); s.set_x(2); if (s.get_x()==1) throw int(2); s.set_y(1); if (s.get_y()!=1) throw int(2); s.set_y(2); if (s.get_y()==1) throw int(2); s.set_color(1); if (s.get_color()!=1) throw int(2); s.set_color(2); if (s.get_color()==1) throw int(2); s.move_left(); if (s.get_x()!=1) throw int(2); s.move_right(); s.move_right(); if (s.get_x()!=3) throw int(2); s.move_down(); if (s.get_color()!=1) throw int(2); for(i=0 ;i<4 ;i++) for(j=0 ;j<4 ;j++) if (s.get_matrix(i,j)) throw int(2); s.Rotate(); if (s.get_dir()!=1) throw int(2); } catch(...) { printf("shape exception!"); } try { Map m1; for(i=0 ;i<4 ;i++) for(j=0 ;j<4 ;j++) if(m1.get_exist(i,j)||m1.get_color(i,j)) throw int(3); Map m2(m1); for(i=0 ;i<4 ;i++) for(j=0 ;j<4 ;j++) if(m2.get_exist(i,j)||m2.get_color(i,j)) throw int(3); if(Map(m1).get_exist(0,0)) throw int(3); Map m3=m1; for(i=0 ;i<4 ;i++) for(j=0 ;j<4 ;j++) if(m3.get_exist(i,j)||m3.get_color(i,j)) throw int(3); Map m4=Map(m1); for(i=0 ;i<4 ;i++) for(j=0 ;j<4 ;j++) if(m4.get_exist(i,j)||m4.get_color(i,j)) throw int(3); } catch(...) { printf("map exception!"); } try { Board b1; if (b1.get_points()!=0) throw int(4); Board b2(b1); if (b2.get_points()!=0) throw int(4); if (b1.add_points(10) != 10) throw int(4); if (Board(b2).get_points()!=0) throw int(4); Board b4=b2; if (b4.get_points()!=0) throw int(4); Board b5=Board(b2); if (b5.get_points()!=0) throw int(4); } catch(...) { printf("board exception!"); } }
TopoShape SimpleBoxWithNaming(){ // We'll do this like freecad, first create TopoDS_Shape const TopoDS_Shape& Box = BRepPrimAPI_MakeBox(10., 10., 10.); // create Base Shape that gets passed to FilletFeature TopoShape BaseShape(Box); //std::clog << "Dumping deep TDF tree\n"; //std::clog << BaseShape.DeepDeepDumpTopoHistory(); // create blank TopoShape in FilletFeature and add Base Shape TopoShape BoxShape; BoxShape.addShape(Box); // Finaly, 'Select' the edge std::cout << "Trying to select the first time" << std::endl; std::string selectionLabel = BoxShape.selectEdge(3); //std::cout << "Trying to select a second time" << std::endl; //std::string selectionLabel2 = BoxShape.selectEdge(3); //std::clog << "Dumping tree" << std::endl; //std::clog << BoxShape.DumpTopoHistory(); //std::clog << "|____________________|" << std::endl; // And fillet the box std::clog << "Running makeTopoShape" << std::endl; BoxShape.makeTopoShapeFillet(2., 2., selectionLabel); //std::clog << "-------------------------" << std::endl; std::clog << "------------ REBUILDING ----------" << std::endl; //std::clog << "-------------------------" << std::endl; // make box taller const TopoDS_Shape& Box2 = BRepPrimAPI_MakeBox(10., 20., 20.); BoxShape.modifyShape("0:2", Box2); std::clog << BoxShape.DumpTopoHistory(); // try re-building the box TopoDS_Edge recoveredEdge = TopoDS::Edge(BoxShape.getSelectedEdge(selectionLabel)); //TopoDS_Shape recoveredBase = BoxShape.getSelectedBaseShape(selectionLabel); //TopoDS_Shape recoveredBase = BoxShape.getNodeShape("0:4"); TopoDS_Shape recoveredBase = BoxShape.getTipShape(); //if (recoveredBase.IsNull()){ //std::cout << "BaseShape is NULL....\n"; //} //else{ //std::cout << "BaseShape is not NULL!!!!\n"; //} //if (recoveredEdge.IsNull()){ //std::cout << "recoveredEdge is Nul..." << std::endl; //} //else{ //std::cout << "recoveredEdge is NOT NULL!!!!" << std::endl; //} TopTools_IndexedMapOfShape edges; TopExp::MapShapes(recoveredBase, TopAbs_EDGE, edges); if (edges.Contains(recoveredEdge)){ std::cout << "Yes the Edge is in the box...\n"; } else{ std::cout << "No, the Edge is not in the Box...\n"; } //BoxShape.makeTopoShapeFillet(2., 2., selectionLabel); return BoxShape; }