当前位置: 首页>>代码示例>>C++>>正文


C++ AABSPTree类代码示例

本文整理汇总了C++中AABSPTree的典型用法代码示例。如果您正苦于以下问题:C++ AABSPTree类的具体用法?C++ AABSPTree怎么用?C++ AABSPTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AABSPTree类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fopen


//.........这里部分代码省略.........
										pMC.append(modelContainer);
									}
									else
									{
										result = false;
									}
								}
							}
							// process the large singe files
							int pos = 0;
							while(result && (pos < nameCollection.iSingeFiles.size()))
							{
								std::string destFileName = iDestDir;
								destFileName.append("/");
								std::string dirEntryName = getDirEntryNameFromModName(pMapId,nameCollection.iSingeFiles[pos]);
								std::string checkDoubleStr = std::string(dirfilename);
								checkDoubleStr.append("##");
								checkDoubleStr.append(nameCollection.iSingeFiles[pos]);
								// Check, if same file already is in the same dir file
								if(!iCoordModelMapping->isAlreadyProcessedSingleFile(checkDoubleStr))
								{
									iCoordModelMapping->addAlreadyProcessedSingleFile(checkDoubleStr);
									fprintf(dirfile, "%s\n",dirEntryName.c_str());
									destFileName.append(dirEntryName);

									Array<std::string> positionarray;
									positionarray.append(nameCollection.iSingeFiles[pos]);

									if(!iCoordModelMapping->isAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos]))
									{
										modelContainer = processNames(positionarray, destFileName.c_str());
										iCoordModelMapping->addAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos]);
										if(modelContainer)
										{
											pMC.append(modelContainer);
										}
										else
										{
											result = false;
										}
									}
								}
								++pos;
							}
							fclose(dirfile);
						}
					}
					return(result);
				}

				//=================================================================

				void removeEntriesFromTree(AABSPTree<SubModel *>* pTree)
				{
					Array<SubModel *> submodelArray;
					pTree->getMembers(submodelArray);
					int no = submodelArray.size();
					while(no > 0)
					{
						--no;
						delete submodelArray[no];
					}
				}

				//=================================================================

				ModelContainer* TileAssembler::processNames(const Array<std::string>& pPositions, const char* pDestFileName)
				{
					ModelContainer *modelContainer = 0;

					Vector3 basepos = Vector3(0,0,0);
					AABSPTree<SubModel *>* mainTree = new AABSPTree<SubModel *>();

					int pos = 0;

					bool result = true;
					while(result && (pos < pPositions.size()))
					{
						std::string modelPosString = pPositions[pos];
						std::string modelFileName = getModNameFromModPosName(modelPosString);

						if(!fillModelIntoTree(mainTree, basepos, modelPosString, modelFileName))
						{
							result = false;
							break;
						}
						++pos;
					}
					if(result && mainTree->size() > 0)
					{
						mainTree->balance();
						modelContainer = new ModelContainer(mainTree);
						modelContainer->writeFile(pDestFileName);
					}
					removeEntriesFromTree(mainTree);

					delete mainTree;

					return(modelContainer);
				}
开发者ID:wow4all,项目名称:wowtbc,代码行数:101,代码来源:TileAssembler.cpp

示例2: fopen

    //=================================================================
    bool TileAssembler::readRawFile(std::string& pModelFilename,  ModelPosition& pModelPosition, AABSPTree<SubModel *> *pMainTree)
    {
        std::string filename = iSrcDir;
        if (filename.length() >0)
            filename.append("/");
        filename.append(pModelFilename);
        FILE *rf = fopen(filename.c_str(), "rb");
        if (!rf)
        {
            // depending on the extractor version, the data could be located in the root dir
            std::string baseModelFilename = pModelFilename.substr((pModelFilename.find_first_of("/")+1),pModelFilename.length());
            filename = iSrcDir;
            if (filename.length() >0)
                filename.append("/");
            filename.append(baseModelFilename);
            rf = fopen(filename.c_str(), "rb");
        }

        if (!rf)
        {
            printf("ERROR: Can't open model file in form: %s",pModelFilename.c_str());
            printf("...                          or form: %s",filename.c_str() );
            return false;
        }

        char ident[8];

        int trianglecount =0;

        #ifdef _ASSEMBLER_DEBUG
        int startgroup = 0;                     //2;
        int endgroup = INT_MAX;                 //2;
        fprintf(::g_df,"-------------------------------------------------\n");
        fprintf(::g_df,"%s\n", pModelFilename.c_str());
        fprintf(::g_df,"-------------------------------------------------\n");
        #else
        int startgroup = 0;
        int endgroup = INT_MAX;
        #endif

        // temporary use defines to simplify read/check code (close file and return at fail)
        #define READ_OR_RETURN(V,S) if (fread((V), (S), 1, rf) != 1) { \
                                        fclose(rf); return(false); }
        #define CMP_OR_RETURN(V,S)  if (strcmp((V),(S)) != 0)        { \
                                        fclose(rf); return(false); }

        READ_OR_RETURN(&ident, 8);
        if (strcmp(ident, "VMAP001") == 0)
        {
            // OK, do nothing
        }
        else if (strcmp(ident, "VMAP002") == 0)
        {
            // we have to read one int. This is needed during the export and we have to skip it here
            int tempNVectors;
            READ_OR_RETURN(&tempNVectors, sizeof(int));

        }
        else
        {
            // wrong version
            fclose(rf);
            return(false);
        }
        G3D::uint32 groups;
        char blockId[5];
        blockId[4] = 0;
        int blocksize;

        READ_OR_RETURN(&groups, sizeof(G3D::uint32));

        for (int g=0;g<(int)groups;g++)
        {
            // group MUST NOT have more then 65536 indexes !! Array will have a problem with that !! (strange ...)
            Array<int> tempIndexArray;
            Array<Vector3> tempVertexArray;

            AABSPTree<Triangle> *gtree = new AABSPTree<Triangle>();

            // add free gtree at fail
            #undef READ_OR_RETURN
            #undef CMP_OR_RETURN
            #define READ_OR_RETURN(V,S) if (fread((V), (S), 1, rf) != 1) { \
                                            fclose(rf); delete gtree; return(false); }
            #define CMP_OR_RETURN(V,S)  if (strcmp((V),(S)) != 0)        { \
                                            fclose(rf); delete gtree; return(false); }

            G3D::uint32 flags;
            READ_OR_RETURN(&flags, sizeof(G3D::uint32));

            G3D::uint32 branches;
            READ_OR_RETURN(&blockId, 4);
            CMP_OR_RETURN(blockId, "GRP ");
            READ_OR_RETURN(&blocksize, sizeof(int));
            READ_OR_RETURN(&branches, sizeof(G3D::uint32));
            for (int b=0;b<(int)branches; b++)
            {
                G3D::uint32 indexes;
                // indexes for each branch (not used jet)
//.........这里部分代码省略.........
开发者ID:Sanzzes,项目名称:wopc-core,代码行数:101,代码来源:TileAssembler.cpp


注:本文中的AABSPTree类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。