# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

ligo_material.cpp

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #include "ligo_material.h"
00027 
00028 // Ligo include
00029 #include "ligo_error.h"
00030 
00031 using namespace NL3D;
00032 
00033 namespace NLLIGO
00034 {
00035 
00036 // ***************************************************************************
00037 
00038 bool CMaterial::build (const CZoneTemplate &tplt, const CLigoConfig &config, CLigoError &errors)
00039 {
00040         // Clear errors
00041         errors.clear ();
00042 
00043         // Edge vector
00044         const std::vector<CZoneEdge> &edges = tplt.getEdges ();
00045 
00046         // This template should have 4 edges
00047         if (edges.size() != 4)
00048         {
00049                 errors.MainError = CLigoError::MustHave4Edges;
00050                 return false;
00051         }
00052 
00053         // The 1st edge must be symetrical
00054         if (!edges[0].isSymetrical (config, errors))
00055                 return false;
00056 
00057         // Error code
00058         bool ok = true;
00059 
00060         // The others must be the same edges
00061         uint edge;
00062         for (edge=1; edge<edges.size(); edge++)
00063         {
00064                 // The same edge ?
00065                 if (!edges[0].isTheSame (edges[edge], config, errors))
00066                 {
00067                         // Error
00068                         ok = false;
00069                 }
00070         }
00071 
00072         // Build ?
00073         if (ok)
00074         {
00075                 // Ok, build the material
00076                 _ZoneEdge = edges[0];
00077         }
00078 
00079         // Return error code
00080         return ok;
00081 }
00082 
00083 // ***************************************************************************
00084 
00085 void CMaterial::serial (NLMISC::IStream &s)
00086 {
00087         // Serial the main node
00088         s.xmlPush ("LIGO_MATERIAL");
00089 
00090                 // Serial the header
00091                 s.serialCheck ((uint32)'TMOL');
00092 
00093                 // Serial the version
00094                 sint ver = s.serialVersion (0);
00095 
00096                 // Serial the zoneedge
00097                 s.xmlSerial (_ZoneEdge, "ZONE_EDGE");
00098 
00099         // Close the main node
00100         s.xmlPop ();
00101 }
00102 
00103 // ***************************************************************************
00104 
00105 }