Exemplo n.º 1
0
		void Parse()
		{
			ReadNextNode();

			WriteElement();

			int nDepth = GetDepth();
			if ( 0 == xmlTextReaderIsEmptyElement(reader) )
			{
				XmlNodeType eNodeType = XmlNodeType_None;

				int nCurDepth = -1;
				// У закрывающего тэга глубина на 1 больше, чем у открывающего
                while( true )
				{
					if ( 1 != xmlTextReaderRead(reader) )
						break;

					int nTempType = xmlTextReaderNodeType(reader);
					if(-1 == nTempType)
						break;
					eNodeType = (XmlNodeType)nTempType;

					nCurDepth = GetDepth();
					if ( eNodeType == XmlNodeType_Text || eNodeType == XmlNodeType_Whitespace || eNodeType == XmlNodeType_SIGNIFICANT_WHITESPACE )
						m_pCurrentNode->m_sText += GetText();
					else if (eNodeType == XmlNodeType_Element)
						WriteElement();
					else if (eNodeType == XmlNodeType_EndElement)
					{
						m_list.pop_back();
						
						if (0 != m_list.size())
						{
							std::list<CXmlNodeBase*>::iterator iter = m_list.end();
							--iter;
							m_pCurrentNode = *iter;
						}
						else
						{
							m_pCurrentNode = m_pNode;
						}
					}

					nCurDepth = GetDepth();
					if ( nCurDepth < nDepth )
						break;

					if ( XmlNodeType_EndElement == eNodeType && nCurDepth == nDepth )
						break;
				}
			}
		}
Exemplo n.º 2
0
void WriteDistriPrefs()
{
	PresetElement** ppElements = g_Presets.GetArray()->GetArray();
	Int32 n, lCount = g_Presets.GetElementCount();
	for (n = 0; n < lCount; n++)
	{
		//g_Presets.Write(pFile, PRESET_FILE_LEVEL);
		WriteElement(ppElements[n]);
	}
}
Exemplo n.º 3
0
int TRI_WriteShapeCollection (TRI_shape_collection_t* collection,
                              TRI_df_marker_t* marker,
                              TRI_voc_size_t markerSize,
                              void const* body,
                              TRI_voc_size_t bodySize,
                              TRI_df_marker_t** result) {
  TRI_datafile_t* journal;
  int res;

  // generate a new tick
  marker->_tick = TRI_NewTickVocBase();

  // lock the collection
  TRI_LockMutex(&collection->_lock);

  if (collection->base._state != TRI_COL_STATE_WRITE) {
    if (collection->base._state == TRI_COL_STATE_READ) {
      TRI_UnlockMutex(&collection->_lock);

      return TRI_ERROR_ARANGO_READ_ONLY;
    }

    TRI_UnlockMutex(&collection->_lock);
    return TRI_ERROR_ARANGO_ILLEGAL_STATE;
  }

  // find and select a journal
  journal = SelectJournal(collection, markerSize + bodySize, result);

  if (journal == NULL) {
    TRI_UnlockMutex(&collection->_lock);

    return TRI_ERROR_ARANGO_NO_JOURNAL;
  }
  
  // generate crc
  TRI_FillCrcMarkerDatafile(journal, marker, markerSize, 0, 0, body, bodySize);

  // and write marker and shape
  res = WriteElement(collection, journal, *result, marker, markerSize, body, bodySize);

  // release lock on collection
  TRI_UnlockMutex(&collection->_lock);

  return res;
}
Exemplo n.º 4
0
// PACK を書き出す
void WritePack(BUF *b, PACK *p)
{
	UINT i;
	// 引数チェック
	if (b == NULL || p == NULL)
	{
		return;
	}

	// ELEMENT 数
	WriteBufInt(b, LIST_NUM(p->elements));

	// ELEMENT を書き出す
	for (i = 0;i < LIST_NUM(p->elements);i++)
	{
		ELEMENT *e = LIST_DATA(p->elements, i);
		WriteElement(b, e);
	}
}
Exemplo n.º 5
0
void Map::WriteSbbData(std::ostream& file) const
{
    char buffer[7];
    int type = (width > 32 ? 1 : 0) | (height > 32 ? 1 : 0) << 1;
    int num_blocks = (type == 0 ? 1 : (type < 3 ? 2 : 4));

    WriteBeginArray(file, "const unsigned short", export_name, "", num_blocks * 32 * 32);
    for (int i = 0; i < num_blocks; i++)
    {
        // Case for each possible value of num_blocks
        // 1: 0
        // 2: type is 1 - 0, 1
        //    type is 2 - 0, 2
        // 4: 0, 1, 2, 3
        int sbb = (i == 0 ? 0 : (i == 1 && type == 2 ? 2 : i));
        unsigned int sx, sy;
        sx = ((sbb & 1) != 0) * 32;
        sy = ((sbb & 2) != 0) * 32;
        for (unsigned int y = 0; y < 32; y++)
        {
            for (unsigned int x = 0; x < 32; x++)
            {
                // Read tile if outside bounds replace with null tile
                unsigned short tile_id;
                if (x + sx > width || y + sy > height)
                    tile_id = 0;
                else
                    tile_id = data[(y + sy) * width + (x + sx)];

                snprintf(buffer, 7, "0x%04x", tile_id);
                // Write it.
                WriteElement(file, buffer, num_blocks * 32 * 32, (y + sy) * width + (x + sx), 8);
            }
        }
    }
    WriteEndArray(file);
    WriteNewLine(file);
}
Exemplo n.º 6
0
  void XmlWriter::WriteNode(const Node& rNode)
  {
    switch (rNode.GetType())
    {
    case Node::TypeElement:
      WriteElement(rNode.GetElement());
      break;

    case Node::TypeText:
      WriteText(static_cast<const Text&>(rNode));
      break;

    case Node::TypeComment:
      WriteComment(static_cast<const Comment&>(rNode));
      break;

    case Node::TypeCdata:
      WriteCdata(static_cast<const Cdata&>(rNode));
      break;

    default:
      STAFF_THROW_ASSERT("Invalid Node Type: " + ToString(rNode.GetType()));
    }
  }
Exemplo n.º 7
0
      /// <summary>Writes a revision</summary>
      /// <param name="r">Revision.</param>
      /// <param name="parent">root node.</param>
      /// <exception cref="Logic::ArgumentNullException">Parent is nullptr</exception>
      void  BackupFileWriter::WriteRevision(const ScriptRevision& r, XmlElementPtr& parent)
      {
         REQUIRED(parent);

         // <revision title="third revision" date="2013-03-12 18:00:00" path="D:\X3 Albion Prelude\scripts\plugin.piracy.lib.logic.xml">  
         auto node = WriteElement(parent, L"revision");
         WriteAttribute(node, L"title", r.Title);
         WriteAttribute(node, L"date", (LPCWSTR)r.Date.Format(L"%Y-%m-%d %H:%M:%S"));  // yyyy-mm-dd hh:mm:ss
         WriteAttribute(node, L"path", r.FullPath.c_str());

         //  <scriptname>plugin.piracy.lib.logic</scriptname>
         //  <version>102</version>
         //  <game>X3TC</game>
         //  <description>Piracy logic library</description>
         //  <command>1019</command>
         //  <text>* Validate Parameters...</text>
         WriteElement(node, L"scriptname", r.ScriptName);
         WriteElement(node, L"version", VString(L"%d", r.Version));
         WriteElement(node, L"game", VersionString(r.Game, true));
         WriteElement(node, L"description", r.Description);
         WriteElement(node, L"command", VString(L"%d", r.CommandID));
         WriteElement(node, L"text", r.Content);
      }
Exemplo n.º 8
0
 void XmlWriter::WriteDocument(const Document& rDocument)
 {
   m_rStream.exceptions(std::ios::failbit | std::ios::badbit);
   WriteDeclaration(rDocument.GetDeclaration());
   WriteElement(rDocument.GetRootElement());
 }
Exemplo n.º 9
0
	XMLElement* ParticleCloud::GenerateParticleCloudSegment(XMLDocument* doc, XSI::ParticleCloud& pointCloud, bool shouldExportGeometry, CString filePath)
	{
		XMLElement* root = doc->NewElement("");

		Geometry oGeom = pointCloud.GetActivePrimitive().GetGeometry();
		CRefArray attributes = oGeom.GetICEAttributes();

		if (Constants::NameInList(attributes, "StrandCount") && Constants::NameInList(attributes, "StrandPosition"))
		{
			if (shouldExportGeometry)
			{
				CString path = CUtils::BuildPath(filePath, pointCloud.GetFullName() + L".hair");
				WriteHairFile(oGeom, path);
			}

			XMLElement* element = doc->NewElement("shape");
			element->SetAttribute(Constants::attrType, "hair");

			element->InsertEndChild(WriteElement(doc, Constants::attrString, "filename", pointCloud.GetFullName() + L".hair"));

			CICEAttributeDataArrayLong dataArraySize;
			oGeom.GetICEAttributeFromName(L"Size").GetDataArray(dataArraySize);
			element->InsertEndChild(WriteElement(doc, Constants::attrFloat, "radius", dataArraySize[0]));

			Mitsuba::Material* material = new Mitsuba::Material();
			material->WriteMeshMaterial(doc, element, pointCloud);
			delete material;

			root->InsertEndChild(element);
		}
		else if (Constants::NameInList(attributes, "Shape"))
		{
			CICEAttributeDataArrayLong dataArrayNbPoints;
			oGeom.GetICEAttributeFromName(L"NbPoints").GetDataArray(dataArrayNbPoints);
			if (dataArrayNbPoints[0] > 0)
			{
				CICEAttributeDataArrayShape dataArrayShape;
				oGeom.GetICEAttributeFromName(L"Shape").GetDataArray(dataArrayShape);

				CICEAttributeDataArrayVector3f dataArrayPointPosition;
				oGeom.GetICEAttributeFromName(L"PointPosition").GetDataArray(dataArrayPointPosition);

				CICEAttributeDataArrayLong dataArraySize;
				oGeom.GetICEAttributeFromName(L"Size").GetDataArray(dataArraySize);

				CICEAttributeDataArrayRotationf dataArrayOrientation;
				oGeom.GetICEAttributeFromName(L"Orientation").GetDataArray(dataArrayOrientation);

				Mitsuba::Primitives* primitives = new Mitsuba::Primitives();
				for (ULONG i = 0; i < dataArrayShape.GetCount(); i++)
				{
					MATH::CVector3f position = dataArrayPointPosition[i];
					MATH::CShape shape = dataArrayShape[i].GetType();
					LONG size = dataArraySize[i];
					MATH::CRotationf rotation = dataArrayOrientation[i];

					//TODO
					/*if (shape == siICEShapeType::siICEShapeSphere)
					{
						root->InsertEndChild(primitives->GenerateSphere(doc, pointCloud, size, position));
					}
					else if (shape == siICEShapeType::siICEShapeBox)
					{
						root->InsertEndChild(primitives->GenerateCube(doc, pointCloud, size, rotation));
					}
					else if (shape == siICEShapeType::siICEShapeCylinder)
					{
						
						root->InsertEndChild(primitives->GenerateCylinder(doc, pointCloud, size, matrix));
					}
					else if (shape == siICEShapeType::siICEShapeRectangle)
					{
						root->InsertEndChild(primitives->GenerateRectangle(doc, pointCloud, size, rotation, position));
					}
					else if (shape == siICEShapeType::siICEShapeDisc)
					{
						root->InsertEndChild(primitives->GenerateDisk(doc, pointCloud, size, rotation));
					}*/
				}
			}
		}

		return root;
	}
Exemplo n.º 10
0
std::string XMLElement::WriteElement(int indent/* = 0*/, bool whitespace/* = true*/) const
{
    std::stringstream ss;
    WriteElement(ss, indent, whitespace);
    return ss.str();
}
Exemplo n.º 11
0
	XMLElement* Mesh::GenerateMeshSegment(XMLDocument* doc, X3DObject& mesh, bool shouldExport, CString exportPath)
	{
		XMLElement* root = nullptr;

		if (MeshIsMassPrimitive(mesh))
		{
			Primitives* primitive = new Primitives();
			root = primitive->WritePrimitive(doc, mesh);
			delete primitive;
		}
		else
		{
			root = doc->NewElement("shape");
			root->SetAttribute(Constants::attrType, "ply");

			root->InsertEndChild(WriteElement(doc, Constants::attrString, Constants::attrFilename, (mesh.GetFullName() + L".ply").GetAsciiString()));

			XMLElement* trElement = doc->NewElement("transform");
			trElement->SetAttribute(Constants::attrName, "toWorld");
			root->InsertEndChild(trElement);

			MATH::CTransformation transform = mesh.GetKinematics().GetGlobal().GetTransform();
			trElement->InsertEndChild(WriteElementScale(doc, mesh));

			trElement->InsertEndChild(WriteSubElementRotation(doc, "x", transform.GetRotX()));
			trElement->InsertEndChild(WriteSubElementRotation(doc, "y", transform.GetRotY()));
			trElement->InsertEndChild(WriteSubElementRotation(doc, "z", transform.GetRotZ()));

			trElement->InsertEndChild(WriteElementTranslate(doc, mesh));

			Mitsuba::Material* material = new Mitsuba::Material();
			material->WriteMeshMaterial(doc, root, mesh);
			delete material;

			if (shouldExport)
			{
				bool isSolid = false;
				bool isSubdivide = false;
				LONG subLevel = 0;

				Property prop;
				mesh.GetPropertyFromName(L"MaSsObjectProperty", prop);
				if (prop.IsValid())
				{
					isSolid = prop.GetParameterValue(L"isSolid");
					isSubdivide = prop.GetParameterValue(L"isSubdivide");
					subLevel = prop.GetParameterValue(L"subLevel");
				}

				if (!isSubdivide)
				{
					Mitsuba::ExportPLY* exportPly = new Mitsuba::ExportPLY();
					exportPly->ExportPlyMeshBinary(mesh, exportPath, mesh.GetFullName() + L".ply", isSolid);
					delete exportPly;
				}
				else
				{
					/*#we should subdivide this mesh and then export
					#lm("We should subdivide the mesh")
					subOps = ap.ApplyOp("MeshSubdivideWithCenter", mesh)
					subMesh = ap.Selection(0)
					subOp = subOps(0)
					ap.SetValue(subOp.SubdivisionDepth, subLevel)
					ap.FreezeObj(subMesh, "", "")

					tM = mesh.Kinematics.Global.Transform.Matrix4
					oTrans = subMesh.Kinematics.Global.Transform
					tM.InvertInPlace()
					oTrans.SetMatrix4(tM)
					subMesh.Kinematics.Global.Transform = oTrans
					ap.ResetTransform(subMesh, "siCtr", "siSRT", "siXYZ")

					ExportPlyMesh02(subMesh, exportPath, mesh.FullName + ".ply")
					ap.DeleteObj(subMesh)*/
				}
			}
		}

		return root;
	}