Skip to content

Commit 190b48c

Browse files
author
hamstahguru
committed
removed NULL references from read functions, made the write functions const.
1 parent 6840739 commit 190b48c

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

topmodx/include/dlflaux/DLFLCrust.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace DLFL {
5555
for normal averaging.
5656
*/
5757

58-
void createCrust(DLFLObjectPtr obj, double thickness, bool uniform) {
58+
void createCrust(const DLFLObjectPtr obj, double thickness, bool uniform) {
5959
if ( !isNonZero(thickness) ) return;
6060

6161
// Clear the arrays used to store crust modeling information

topmodx/include/dlflaux/DLFLDual.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
namespace DLFL {
3939

40-
void createDual(DLFLObjectPtr obj, bool accurate) {
40+
void createDual(const DLFLObjectPtr obj, bool accurate) {
4141
// Using "correct" methods seems to be VERY slow
4242
// We will use it only if we want accurate dual
4343
// Otherwise we will use old method

topmodx/include/dlflaux/DLFLDual.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <DLFLObject.hh>
3333

3434
namespace DLFL {
35-
void createDual(DLFLObjectPtr obj, bool accurate = false);
35+
void createDual(const DLFLObjectPtr obj, bool accurate = false);
3636
}
3737

3838
#endif // _DLFLDUAL_H_

topmodx/include/dlflcore/DLFLFile.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ namespace DLFL {
205205
// std::cout << "done reading obj\n;";
206206
}
207207

208-
void DLFLObject::writeObject(ostream& o, ostream &omtl, bool with_normals, bool with_tex_coords) {
208+
void DLFLObject::writeObject(ostream& o, ostream &omtl, bool with_normals, bool with_tex_coords) const {
209209
//write mtl file
210210
if (!omtl.fail())
211211
writeMTL(omtl);
@@ -504,7 +504,7 @@ namespace DLFL {
504504
// printEdgeList();
505505
}
506506

507-
void DLFLObject::writeDLFL(ostream& o, ostream &omtl, bool reverse_faces) {
507+
void DLFLObject::writeDLFL(ostream& o, ostream &omtl, bool reverse_faces) const {
508508
//write the mtl file if it exists
509509
if (!omtl.fail()){
510510
// std::cout<<"mtl file did not fail.\n";
@@ -519,7 +519,7 @@ namespace DLFL {
519519
// std::cout << "writing dlfl\t" << mFilename << "\n";
520520

521521
// Write the vertex list next. Update the vertex index also
522-
DLFLVertexPtrList::iterator vf = vertex_list.begin(), vl = vertex_list.end();
522+
DLFLVertexPtrList::const_iterator vf = vertex_list.begin(), vl = vertex_list.end();
523523
uint vindex = 0;
524524
while ( vf != vl ) {
525525
(*vf)->writeDLFL(o,vindex++);
@@ -528,7 +528,7 @@ namespace DLFL {
528528
o << '#' << endl;
529529

530530
// Write the face vertices and update the face vertex index also
531-
DLFLFacePtrList::iterator ff = face_list.begin(), fl = face_list.end();
531+
DLFLFacePtrList::const_iterator ff = face_list.begin(), fl = face_list.end();
532532
DLFLFacePtr fptr;
533533
uint fvindex = 0;
534534
while ( ff != fl ) {
@@ -549,7 +549,7 @@ namespace DLFL {
549549
o << '#' << endl;
550550

551551
// Write the edge list
552-
DLFLEdgePtrList::iterator ef = edge_list.begin(), el = edge_list.end();
552+
DLFLEdgePtrList::const_iterator ef = edge_list.begin(), el = edge_list.end();
553553
if ( reverse_faces ) {
554554
while ( ef != el ) {
555555
(*ef)->writeDLFLReverse(o);
@@ -619,7 +619,7 @@ namespace DLFL {
619619
return true;
620620
}
621621

622-
bool DLFLObject::writeMTL( ostream& o ) {
622+
bool DLFLObject::writeMTL( ostream& o ) const {
623623

624624
// newmtl blinn1SG
625625
// illum 4
@@ -657,11 +657,11 @@ namespace DLFL {
657657

658658
}
659659

660-
void DLFLObject::writeLG3d(ostream& o, bool selected) {
660+
void DLFLObject::writeLG3d(ostream& o, bool selected) const {
661661

662662
Vector3dArray coords; int i=0, j=0;
663663
if (selected){
664-
vector<DLFLFacePtr>::iterator ff = this->sel_fptr_array.begin(),
664+
vector<DLFLFacePtr>::const_iterator ff = this->sel_fptr_array.begin(),
665665
fl = this->sel_fptr_array.end();
666666
// Write the object in LG3d (*.m) format for use with the LiveGraphics3D live.jar java archive from Mathworld.com
667667
o << "Graphics3D[{";
@@ -687,7 +687,7 @@ namespace DLFL {
687687

688688
}
689689
else {
690-
DLFLFacePtrList::iterator ff, fl;
690+
DLFLFacePtrList::const_iterator ff, fl;
691691
ff = face_list.begin();
692692
fl = face_list.end();
693693
// Write the object in LG3d (*.m) format for use with the LiveGraphics3D live.jar java archive from Mathworld.com
@@ -714,7 +714,7 @@ namespace DLFL {
714714
}
715715
}
716716

717-
void DLFLObject::writeSTL(ostream& o){
717+
void DLFLObject::writeSTL(ostream& o) const{
718718
// if(binary)
719719
// {
720720
// // Write Header
@@ -742,8 +742,8 @@ namespace DLFL {
742742
// }
743743
// else
744744
// {
745-
DLFLFacePtrList::iterator ff = face_list.begin();
746-
DLFLFacePtrList::iterator fl = face_list.end();
745+
DLFLFacePtrList::const_iterator ff = face_list.begin();
746+
DLFLFacePtrList::const_iterator fl = face_list.end();
747747
Vector3dArray coords; int i=0;
748748

749749
o << "solid ascii\n";

topmodx/include/dlflcore/DLFLObject.hh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -530,16 +530,16 @@ public :
530530
void boundaryWalk(uint face_index);
531531
void vertexTrace(uint vertex_index);
532532

533-
void readObject( istream& i, istream &imtl = NULL );
533+
void readObject( istream& i, istream &imtl );
534534
void readObjectAlt( istream& i );
535-
void readDLFL( istream& i, istream &imtl = NULL, bool clearold = true );
535+
void readDLFL( istream& i, istream &imtl , bool clearold = true );
536536
bool readMTL( istream &i);
537-
bool writeMTL( ostream& o );
537+
bool writeMTL( ostream& o ) const;
538538

539-
void writeObject( ostream& o, ostream &omtl = NULL, bool with_normals = true, bool with_tex_coords = true );
540-
void writeDLFL(ostream& o, ostream &omtl = NULL, bool reverse_faces = false);
541-
void writeSTL(ostream& o);
542-
void writeLG3d(ostream& o, bool select = false); //!< added by dave - for LiveGraphics3D support to embed 3d models into html
539+
void writeObject( ostream& o, ostream &omtl , bool with_normals = true, bool with_tex_coords = true ) const;
540+
void writeDLFL(ostream& o, ostream &omtl, bool reverse_faces = false) const;
541+
void writeSTL(ostream& o) const;
542+
void writeLG3d(ostream& o, bool select = false) const ; //!< added by dave - for LiveGraphics3D support to embed 3d models into html
543543
inline void setFilename( const char *filename ) {
544544
// if( mFilename) { delete [] mFilename; mFilename = NULL; }
545545
// mFilename = filename;

0 commit comments

Comments
 (0)