PLearn 0.1
|
A molecular surface, represented by a list of points and features on them. More...
#include <Molecule.h>
Public Member Functions | |
Molecule () | |
Molecule (PLearn::Mat _chem, PLearn::Mat _geom, string vrml_file="") | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual Molecule * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
Molecule () | |
Default constructor. | |
Molecule (const PPath &filename) | |
Constructor from files (call readFromFile). Usually used. | |
virtual void | readFromFile (const PPath &filename) |
reads geometry from filename.vrml and features from filename.amat | |
virtual void | writeToFile (const PPath &filename) |
writes geometry in filename.vrml and features in filename.amat | |
int | n_points () |
returns the number of points on the surface | |
virtual int | n_features () |
returns the dimension of the features vector | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual Molecule * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
Static Public Member Functions | |
static string | _classname_ () |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
static std::string | getVrmlType (const std::string &name) |
static void | readVrml (const std::string &name, PLearn::SurfMesh &sm) |
static void | writeVrml (const std::string &name, const std::string &to, PLearn::SurfMesh &sm) |
static void | getVrmlVertexCoords (const std::string &name, PLearn::Mat &xmat) |
static void | readMolecules (const std::string &fileName, std::vector< PMolecule > &storage) |
static PMolecule | readMolecule (const std::string &fileName) |
static string | _classname_ () |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Public Attributes | |
PLearn::Mat | chem |
PLearn::Mat | geom |
string | vrml_file |
Mat | coordinates |
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //! | |
Mat | features |
Mat containing the values of the chemical features at each point. | |
TVec< string > | feature_names |
Name of the chemical features stored in 'features'. | |
TVec< int > | vrml_face_set |
List of point indices, used to define faces in VRML. | |
TVec< int > | vrml_line_set |
List of point indices, used to define lines in VRML. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
virtual void | readFromVRMLFile (const PPath &filename) |
Reads geometric informations from file. | |
virtual void | readFromAMATFile (const PPath &filename) |
Reads features informations from file. | |
virtual void | writeToVRMLFile (const PPath &filename) |
Saves the geometric informations in file. | |
virtual void | writeToAMATFile (const PPath &filename) |
Saves the features informations in file. | |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares this class' options. | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef Object | inherited |
typedef Object | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. | |
void | build_ () |
This does the actual building. |
A molecular surface, represented by a list of points and features on them.
The 3D coordinates and values of some chemical features are stored, as well as the name of these features, and informations that allow to save it as a VRML file. This class is usually built from a pair of (.vrml, .amat) files, or by deepCopy of an existing object.
Definition at line 21 of file Molecule.h.
typedef Object PLearn::Molecule::inherited [private] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 24 of file Molecule.h.
typedef Object PLearn::Molecule::inherited [private] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 62 of file SurfaceTemplate/Molecule.h.
PLearn::Molecule::Molecule | ( | ) |
Definition at line 9 of file Molecule.cc.
{}
PLearn::Molecule::Molecule | ( | PLearn::Mat | _chem, |
PLearn::Mat | _geom, | ||
string | vrml_file = "" |
||
) |
Definition at line 10 of file Molecule.cc.
References PLearn::TMat< T >::length(), PLearn::TMat< T >::resize(), and PLearn::TMat< T >::width().
{ chem.resize(_chem.length(), _chem.width() ) ; chem << _chem ; geom.resize(_geom.length(), _geom.width() ) ; geom << _geom ; this->vrml_file = vrml_file ; }
PLearn::Molecule::Molecule | ( | ) |
Default constructor.
PLearn::Molecule::Molecule | ( | const PPath & | filename | ) |
Constructor from files (call readFromFile). Usually used.
Definition at line 61 of file SurfaceTemplate/Molecule.cc.
{ readFromFile( filename ); build(); }
string PLearn::Molecule::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
static string PLearn::Molecule::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
OptionList & PLearn::Molecule::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
static OptionList& PLearn::Molecule::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
RemoteMethodMap & PLearn::Molecule::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
static RemoteMethodMap& PLearn::Molecule::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
static Object* PLearn::Molecule::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Object * PLearn::Molecule::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
static void PLearn::Molecule::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
StaticInitializer Molecule::_static_initializer_ & PLearn::Molecule::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
virtual void PLearn::Molecule::build | ( | ) | [virtual] |
Post-constructor.
The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
void PLearn::Molecule::build | ( | ) | [virtual] |
Post-constructor.
The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 45 of file Molecule.cc.
Referenced by PLearn::Template::build().
{ inherited::build(); build_(); }
void PLearn::Molecule::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
void PLearn::Molecule::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 42 of file Molecule.cc.
{}
string PLearn::Molecule::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
virtual string PLearn::Molecule::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
void PLearn::Molecule::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares this class' options.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 25 of file Molecule.cc.
References PLearn::declareOption().
Referenced by PLearn::Template::declareOptions().
{ declareOption(ol, "chem", &Molecule::chem, OptionBase::buildoption, "Chemical Properties"); declareOption(ol, "geom", &Molecule::geom, OptionBase::buildoption, "Geom Properties"); declareOption(ol, "vrml_file", &Molecule::vrml_file, OptionBase::buildoption, "The vrml filename"); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static void PLearn::Molecule::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
static const PPath& PLearn::Molecule::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 110 of file SurfaceTemplate/Molecule.h.
:
//##### Protected Options ###############################################
static const PPath& PLearn::Molecule::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 47 of file Molecule.h.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
OptionList & PLearn::Molecule::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
virtual OptionList& PLearn::Molecule::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
virtual OptionMap& PLearn::Molecule::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
OptionMap & PLearn::Molecule::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
RemoteMethodMap & PLearn::Molecule::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 23 of file Molecule.cc.
virtual RemoteMethodMap& PLearn::Molecule::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
string PLearn::Molecule::getVrmlType | ( | const std::string & | name | ) | [static] |
Definition at line 60 of file Molecule.cc.
{ string name2 = name + ".vrml"; ifstream os(name2.c_str()); string temp,s; s=""; while(os>>temp){ s=s+temp; } string::size_type a = s.find("Line"); if (a!= string::npos) return string("line"); a = s.find("Face"); if (a!=string::npos) return string("face"); PLERROR("getType : Invalid VRML file"); return ""; }
void PLearn::Molecule::getVrmlVertexCoords | ( | const std::string & | name, |
PLearn::Mat & | xmat | ||
) | [static] |
Definition at line 93 of file Molecule.cc.
virtual void PLearn::Molecule::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
void PLearn::Molecule::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 51 of file Molecule.cc.
References PLearn::deepCopyField().
Referenced by PLearn::Template::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(chem, copies); deepCopyField(geom, copies); }
virtual int PLearn::Molecule::n_features | ( | ) | [inline, virtual] |
returns the dimension of the features vector
Definition at line 104 of file SurfaceTemplate/Molecule.h.
Referenced by PLearn::MoleculeTemplate::build_(), and PLearn::MoleculeTemplate::writeToAMATFile().
{ return features.width(); }
int PLearn::Molecule::n_points | ( | ) | [inline] |
returns the number of points on the surface
Definition at line 101 of file SurfaceTemplate/Molecule.h.
Referenced by PLearn::MoleculeTemplate::build_(), and PLearn::ScoreLayerVariable::build_().
{ return coordinates.length(); }
void PLearn::Molecule::readFromAMATFile | ( | const PPath & | filename | ) | [protected, virtual] |
Reads features informations from file.
Reimplemented in PLearn::MoleculeTemplate.
Definition at line 153 of file SurfaceTemplate/Molecule.cc.
References PLearn::TMat< T >::compact(), PLearn::getDataSet(), and PLearn::VMat::toMat().
{ // Read the chemical informations, contained in an AMAT file VMat features_ = getDataSet( filename ); features = features_->toMat(); features.compact(); // for use as Var storage feature_names = features_->fieldNames(); }
void PLearn::Molecule::readFromFile | ( | const PPath & | filename | ) | [virtual] |
reads geometry from filename.vrml and features from filename.amat
Definition at line 67 of file SurfaceTemplate/Molecule.cc.
Referenced by PLearn::MoleculeTemplate::MoleculeTemplate().
{ readFromVRMLFile( filename + ".vrml" ); readFromAMATFile( filename + ".amat" ); }
void PLearn::Molecule::readFromVRMLFile | ( | const PPath & | filename | ) | [protected, virtual] |
Reads geometric informations from file.
Definition at line 99 of file SurfaceTemplate/Molecule.cc.
References PLearn::loadFileAsString(), PLearn::openString(), PLearn::PStream::plearn_ascii, PLERROR, and PLearn::TVec< T >::toMat().
{ // Read the geometrical informations, contained in a VRML file string vrml = loadFileAsString( filename ); // Read the coordinates, and store them in coordinates size_t begin; size_t end; begin = vrml.find( "Coordinate3" ); if( begin != string::npos ) { begin = vrml.find( "[", begin ); end = vrml.find( "]", begin ); string coordinate3 = vrml.substr( begin, end - begin + 1 ); PStream coords = openString( coordinate3, PStream::plearn_ascii ); Vec coordinates_; coords >> coordinates_; coordinates = coordinates_->toMat( coordinates_->length() / 3, 3 ); } else PLERROR("Molecule::readFromFile - File %s.vrml should contain a" " 'Coordinate3' block.\n", filename.c_str()); // Read the other geometrical informations (edges or faces) // Search for edges informations begin = vrml.find( "IndexedFaceSet" ); if( begin != string::npos ) { begin = vrml.find( "[", begin ); end = vrml.find( "]", begin ); // store them in vrml_face_set string indexedfaceset = vrml.substr( begin, end - begin + 1 ); PStream face_indices = openString( indexedfaceset, PStream::plearn_ascii ); face_indices >> vrml_face_set; } // Search for edges informations begin = vrml.find( "IndexedLineSet" ); if( begin != string::npos ) { begin = vrml.find( "[", begin ); end = vrml.find( "]", begin ); // store them in vrml_line_set string indexedlineset = vrml.substr( begin, end - begin + 1 ); PStream line_indices = openString( indexedlineset, PStream::plearn_ascii ); line_indices >> vrml_line_set; } }
PMolecule PLearn::Molecule::readMolecule | ( | const std::string & | fileName | ) | [static] |
Definition at line 100 of file Molecule.cc.
References PLearn::getDataSet(), i, PLearn::TMat< T >::length(), PLearn::normalize(), PLearn::TMat< T >::resize(), PLearn::selectColumns(), and PLearn::VMat::toMat().
Referenced by PLearn::WeightedLogGaussian::fprop().
{ Vec column_indices(5) ; for(int i=0 ; i<5 ; ++i) column_indices[i] = i ; Mat chem, geom ; VMat t = getDataSet(file + ".amat") ; Mat full_chem = t.toMat() ; chem.resize(full_chem.length() ,5 ) ; selectColumns(full_chem , column_indices , chem) ; normalize(chem) ; Molecule::getVrmlVertexCoords(file,geom); // Molecule m(chem,geom) ; PMolecule pm = new Molecule(chem , geom ,file+".vrml" ) ; return pm ; }
void PLearn::Molecule::readMolecules | ( | const std::string & | fileName, |
std::vector< PMolecule > & | storage | ||
) | [static] |
Definition at line 120 of file Molecule.cc.
Referenced by PLearn::MoleculeTemplateLearner::build_().
{ ifstream f(fileName.c_str()); string file; while(f>>file){ // load(file+"SurfacePrpi.mat",chem); storage.push_back(readMolecule(file)) ; } }
void PLearn::Molecule::readVrml | ( | const std::string & | name, |
PLearn::SurfMesh & | sm | ||
) | [static] |
Definition at line 76 of file Molecule.cc.
{ string type = getVrmlType(name); if(type=="line"){ sm->readVRMLIndexedLineSet(name+".vrml"); }else if(type=="face"){ sm->readVRMLIndexedFaceSet(name+".vrml"); } }
void PLearn::Molecule::writeToAMATFile | ( | const PPath & | filename | ) | [protected, virtual] |
Saves the features informations in file.
Reimplemented in PLearn::MoleculeTemplate.
Definition at line 239 of file SurfaceTemplate/Molecule.cc.
{ VMat features_ = new MemoryVMatrix( features ); features_->declareFieldNames( feature_names ); features_->saveAMAT( filename, false ); }
void PLearn::Molecule::writeToFile | ( | const PPath & | filename | ) | [virtual] |
writes geometry in filename.vrml and features in filename.amat
Definition at line 73 of file SurfaceTemplate/Molecule.cc.
{ writeToVRMLFile( filename + ".vrml" ); writeToAMATFile( filename + ".amat" ); }
void PLearn::Molecule::writeToVRMLFile | ( | const PPath & | filename | ) | [protected, virtual] |
Saves the geometric informations in file.
Definition at line 163 of file SurfaceTemplate/Molecule.cc.
References PLearn::endl(), i, j, PLearn::openFile(), and PLearn::PStream::raw_ascii.
{ PStream vrml = openFile( filename, PStream::raw_ascii, "w" ); // writes VRML header and beginning of file vrml<< "#VRML V1.0 ascii" << endl << endl << "Separator {" << endl << " Material {" << endl << " diffuseColor [ 1 1 1 ]" << endl << " }" << endl << endl; // writes coordinates vrml<< " Coordinate3 {" << endl << " point [" << endl; for( int i=0 ; i<coordinates.length() ; i++ ) { vrml<< " "; for( int j=0 ; j<3 ; j++ ) vrml<< coordinates(i,j) << " "; vrml<< "," << endl; } vrml<< " ]" << endl << " }" << endl << endl; // writes FaceSet (if any) int faceset_size = vrml_face_set.size(); if( faceset_size > 0 ) { vrml<< " IndexedFaceSet {" << endl << " coordIndex [" << endl << " " ; for( int i=0 ; i<faceset_size ; i++ ) { int index = vrml_face_set[i]; if( index < 0 ) vrml<< "-1," << endl << " "; else vrml<< index << ", "; } vrml<< "]" << endl << " }" << endl << endl; } // writes LineSet (if any) int lineset_size = vrml_line_set.size(); if( lineset_size > 0 ) { vrml<< " IndexedLineSet {" << endl << " coordIndex [" << endl << " " ; for( int i=0 ; i<lineset_size ; i++ ) { int index = vrml_line_set[i]; if( index < 0 ) vrml<< "-1," << endl << " "; else vrml<< index << ", "; } vrml<< "]" << endl << " }" << endl << endl; } // end of the file vrml<< "}" << endl; }
void PLearn::Molecule::writeVrml | ( | const std::string & | name, |
const std::string & | to, | ||
PLearn::SurfMesh & | sm | ||
) | [static] |
Definition at line 84 of file Molecule.cc.
{ string type = getVrmlType(name); if(type=="line"){ sm->writeVRMLIndexedLineSet(to+".vrml"); }else if(type=="face"){ sm->writeVRMLIndexedFaceSet(to+".vrml"); } }
static StaticInitializer PLearn::Molecule::_static_initializer_ [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::MoleculeTemplate, and PLearn::Template.
Definition at line 47 of file Molecule.h.
Definition at line 28 of file Molecule.h.
Referenced by PLearn::WeightedLogGaussian::fprop(), and performLP().
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
Mat containing the 3D coordinates of the surface points.
Definition at line 71 of file SurfaceTemplate/Molecule.h.
TVec<string> PLearn::Molecule::feature_names |
Name of the chemical features stored in 'features'.
Definition at line 77 of file SurfaceTemplate/Molecule.h.
Referenced by PLearn::ScoreLayerVariable::build_(), PLearn::MoleculeTemplate::readFromAMATFile(), and PLearn::MoleculeTemplate::writeToAMATFile().
Mat containing the values of the chemical features at each point.
Definition at line 74 of file SurfaceTemplate/Molecule.h.
Referenced by PLearn::MoleculeTemplate::readFromAMATFile(), and PLearn::MoleculeTemplate::writeToAMATFile().
Definition at line 29 of file Molecule.h.
Referenced by performLP().
List of point indices, used to define faces in VRML.
Definition at line 80 of file SurfaceTemplate/Molecule.h.
string PLearn::Molecule::vrml_file |
Definition at line 30 of file Molecule.h.
Referenced by PLearn::WeightedLogGaussian::fprop().
List of point indices, used to define lines in VRML.
Definition at line 83 of file SurfaceTemplate/Molecule.h.