#include <BrepLib.h>
Public Member Functions | |
BrepSolidList (void) | |
virtual | ~BrepSolidList (void) |
void | init (void) |
void | clear (void) |
void | free (void) |
int | addObject (MeshObjectData *mesh) |
int | addSolid (MeshObjectData *mesh) |
void | outputFile (const char *fn, const char *path=NULL, bool binfile=true) |
BREP_SOLID * | getMerge (CVCounter *counter=NULL) |
Public Attributes | |
BREP_SOLID_LIST | solid_list |
Definition at line 30 of file BrepLib.h.
BrepSolidList | ( | void | ) | [inline] |
Definition at line 33 of file BrepLib.h.
References BrepSolidList::init().
00033 { init();}
~BrepSolidList | ( | void | ) | [virtual] |
Definition at line 19 of file BrepLib.cpp.
References DEBUG_INFO.
00020 { 00021 DEBUG_INFO("DESTRUCTOR: BrepSolidList"); 00022 }
int addObject | ( | MeshObjectData * | mesh | ) | [inline] |
Definition at line 45 of file BrepLib.h.
References BrepSolidList::addSolid().
00045 { return addSolid(mesh);} // 有効なファセットの数を返す
int addSolid | ( | MeshObjectData * | mesh | ) |
Definition at line 60 of file BrepLib.cpp.
References MeshObjectData::affine_trans, jbxl::BREP_FACET, jbxl::BREP_SHELL, jbxl::BREP_SOLID, jbxl::CloseTriSolid(), BREP_SOLID::contours, jbxl::CreateContourByVector(), MeshObjectNode::data_index, jbxl::deleteNull(), AffineTrans< T >::execRotate(), AffineTrans< T >::execTrans(), BREP_SOLID::facetno, BrepSolidList::free(), jbxl::GetOctreeVertices(), MeshObjectNode::next, MeshObjectData::nodelist, BREP_VERTEX::normal, MeshObjectNode::normal_value, MeshObjectNode::num_index, BREP_SOLID::octree, BREP_VERTEX::point, BrepSolidList::solid_list, and MeshObjectNode::vertex_value.
Referenced by BrepSolidList::addObject().
00061 { 00062 if (mesh==NULL) return 0; 00063 00064 Vector<double> vertex[3]; 00065 Vector<double> normal[3]; 00066 00067 BREP_SOLID* solid = new BREP_SOLID(); 00068 BREP_SHELL* shell = new BREP_SHELL(solid); 00069 00070 MeshObjectNode* node = mesh->nodelist; 00071 00072 while (node!=NULL) { 00073 // 00074 for (int num=0; num<node->num_index-2; num+=3) { 00075 BREP_FACET* facet = new BREP_FACET(shell); 00076 // 00077 int idx0 = node->data_index[num]; 00078 int idx1 = node->data_index[num+1]; 00079 int idx2 = node->data_index[num+2]; 00080 00081 vertex[0] = node->vertex_value[idx0]; 00082 vertex[1] = node->vertex_value[idx1]; 00083 vertex[2] = node->vertex_value[idx2]; 00084 normal[0] = node->normal_value[idx0]; 00085 normal[1] = node->normal_value[idx1]; 00086 normal[2] = node->normal_value[idx2]; 00087 00088 BREP_CONTOUR* contour = CreateContourByVector(facet, vertex, normal, NULL, false); 00089 if (contour!=NULL) { 00090 solid->contours.push_back(contour); 00091 } 00092 else { 00093 deleteNull(facet); 00094 } 00095 } 00096 node = node->next; 00097 } 00098 00099 int fno = CloseTriSolid(solid, false, NULL); 00100 solid->facetno = fno; 00101 00102 // 00103 if (mesh->affine_trans!=NULL) { 00104 long int vnum; 00105 BREP_VERTEX** vertex_data = GetOctreeVertices(solid->octree, &vnum); 00106 00107 for (long int i=0; i<vnum; i++) { 00108 vertex_data[i]->point = mesh->affine_trans->execTrans (vertex_data[i]->point); 00109 vertex_data[i]->normal = mesh->affine_trans->execRotate(vertex_data[i]->normal); 00110 } 00111 ::free(vertex_data); 00112 } 00113 00114 solid_list.push_back(solid); 00115 00116 return fno; 00117 }
void clear | ( | void | ) |
Definition at line 43 of file BrepLib.cpp.
References BrepSolidList::solid_list.
00044 { 00045 BREP_SOLID_LIST::iterator isolid; 00046 for (isolid=solid_list.begin(); isolid!=solid_list.end(); isolid++) (*isolid)->FreeData(); 00047 00048 solid_list.clear(); 00049 }
void free | ( | void | ) |
Definition at line 33 of file BrepLib.cpp.
References jbxl::freeBrepSolid(), and BrepSolidList::solid_list.
Referenced by BrepSolidList::addSolid(), jbxl::freeBrepSolidList(), and BrepSolidList::outputFile().
00034 { 00035 BREP_SOLID_LIST::iterator isolid; 00036 for (isolid=solid_list.begin(); isolid!=solid_list.end(); isolid++) freeBrepSolid(*isolid); 00037 00038 solid_list.clear(); 00039 }
BREP_SOLID * getMerge | ( | CVCounter * | counter = NULL |
) |
Definition at line 156 of file BrepLib.cpp.
References jbxl::BREP_FACET, jbxl::BREP_SHELL, jbxl::BREP_SOLID, jbxl::CloseTriSolid(), BREP_SOLID::contours, jbxl::CreateContourByVector(), jbxl::deleteNull(), BREP_SOLID::facetno, CVCounter::GetUsableCounter(), BREP_WING::next, BREP_VERTEX::normal, BREP_VERTEX::point, BrepSolidList::solid_list, CVCounter::Start(), CVCounter::StepIt(), and BREP_WING::vertex.
00157 { 00158 BREP_SOLID* solid = new BREP_SOLID(); 00159 BREP_SHELL* shell = new BREP_SHELL(solid); 00160 00161 // Counter 00162 if (counter!=NULL) { 00163 int maxnum = 0; 00164 BREP_SOLID_LIST::iterator isolid; 00165 for (isolid=solid_list.begin(); isolid!=solid_list.end(); isolid++){ 00166 BREP_CONTOUR_LIST::iterator icon; 00167 for (icon=(*isolid)->contours.begin(); icon!=(*isolid)->contours.end(); icon++){ 00168 maxnum++; 00169 } 00170 } 00171 counter->GetUsableCounter(); 00172 counter->Start(maxnum); 00173 } 00174 00175 BREP_SOLID_LIST::iterator isolid; 00176 for (isolid=solid_list.begin(); isolid!=solid_list.end(); isolid++){ 00177 // 00178 BREP_CONTOUR_LIST::iterator icon; 00179 for (icon=(*isolid)->contours.begin(); icon!=(*isolid)->contours.end(); icon++){ 00180 Vector<double> vect[3]; 00181 Vector<double> norm[3]; 00182 // 00183 BREP_WING* wing = (*icon)->wing; 00184 for (int i=0; i<3; i++) { 00185 vect[i] = wing->vertex->point; 00186 norm[i] = wing->vertex->normal; 00187 wing = wing->next; 00188 } 00189 // 00190 BREP_FACET* facet = new BREP_FACET(shell); 00191 BREP_CONTOUR* contour = CreateContourByVector(facet, vect, norm, NULL, false); 00192 if (contour!=NULL) solid->contours.push_back(contour); 00193 else deleteNull(facet); 00194 // 00195 if (counter!=NULL) counter->StepIt(); 00196 } 00197 } 00198 00199 int fno = CloseTriSolid(solid, false, NULL); 00200 solid->facetno = fno; 00201 00202 return solid; 00203 }
void init | ( | void | ) |
Definition at line 26 of file BrepLib.cpp.
References BrepSolidList::solid_list.
Referenced by BrepSolidList::BrepSolidList().
00027 { 00028 solid_list.clear(); 00029 }
void outputFile | ( | const char * | fn, | |
const char * | path = NULL , |
|||
bool | binfile = true | |||
) |
Definition at line 121 of file BrepLib.cpp.
References Buffer::buf, cat_Buffer(), change_file_extension_Buffer(), BrepSolidList::free(), free_Buffer(), get_file_name(), make_Buffer_bystr, pack_head_tail_char(), rewrite_sBuffer_bystr(), BrepSolidList::solid_list, jbxl::WriteSTLFileA(), and jbxl::WriteSTLFileB().
00122 { 00123 char* packname = pack_head_tail_char(get_file_name(fname), ' '); 00124 Buffer file_name = make_Buffer_bystr(packname); 00125 ::free(packname); 00126 00127 rewrite_sBuffer_bystr(&file_name, ":", "_"); 00128 rewrite_sBuffer_bystr(&file_name, "*", "_"); 00129 rewrite_sBuffer_bystr(&file_name, "?", "_"); 00130 rewrite_sBuffer_bystr(&file_name, "\"", "_"); 00131 rewrite_sBuffer_bystr(&file_name, "<", "_"); 00132 rewrite_sBuffer_bystr(&file_name, ">", "_"); 00133 if (file_name.buf[0]=='.') file_name.buf[0] = '_'; 00134 // 00135 Buffer out_path; 00136 if (path==NULL) out_path = make_Buffer_bystr("./"); 00137 else out_path = make_Buffer_bystr(path); 00138 cat_Buffer(&file_name, &out_path); 00139 change_file_extension_Buffer(&out_path, ".stl"); 00140 // 00141 if (binfile) { 00142 WriteSTLFileB((char*)out_path.buf, solid_list); 00143 } 00144 else { 00145 WriteSTLFileA((char*)out_path.buf, solid_list); 00146 } 00147 00148 free_Buffer(&file_name); 00149 free_Buffer(&out_path); 00150 00151 return; 00152 }
Definition at line 37 of file BrepLib.h.
Referenced by BrepSolidList::addSolid(), BrepSolidList::clear(), BrepSolidList::free(), BrepSolidList::getMerge(), BrepSolidList::init(), and BrepSolidList::outputFile().