几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-05-05, 11:12 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】geometry related questions

geometry related questions.
geometry related questions.
hi !
i am new to opendwg and am using the dwg libraries to fetch the geometric / rendering data of a dwg file. please can someone help me with following questions.
1) how can we identify the type of solid once its read i-e if its a sphere, wedge, box or even some arbitrarily extruded / revolved solid. i basically need the vertex / face information for all sorts of objects. so if there is a way of getting that information without identifying the type of object, that will do as well. i know that one way will be to repeatedly explode the objects until we are left with basic primitives such as lines/arcs. but i am sure there will be a better way of doing it.
2) how can we identify as to which material is attatched to which object. also how to read the the properties associated with a material, such as the texture, reflection, refraction, ambient and other properties.
3) how do we read the lighting information in a model.
4) we know that different files are referenced by a given dwg file. in that case how can we get information of those referenced files i-e their names. also does opendwg opens the referenced files itself or do we have to open them by fetching their names and opening them manually.
basically what i am trying to do is to read a dwg file and convert all the geometric information into a mesh. this work has been done in gl based examples that come with dwg. however they are using the vectorization libraries provided by dwg. i can't get to access the rendering code, where each object is converted to vertex and face information, that in turn is used for the purpose of rendering. so is there a way i can access the code, where the geometric data of different objects is being extracted using dwg.
regards.
quote:
originally posted by trivor
hi !
i am new to opendwg and am using the dwg libraries to fetch the geometric / rendering data of a dwg file. please can someone help me with following questions.
1) how can we identify the type of solid once its read i-e if its a sphere, wedge, box or even some arbitrarily extruded / revolved solid. i basically need the vertex / face information for all sorts of objects. so if there is a way of getting that information without identifying the type of object, that will do as well. i know that one way will be to repeatedly explode the objects until we are left with basic primitives such as lines/arcs. but i am sure there will be a better way of doing it.
2) how can we identify as to which material is attatched to which object. also how to read the the properties associated with a material, such as the texture, reflection, refraction, ambient and other properties.
3) how do we read the lighting information in a model.
4) we know that different files are referenced by a given dwg file. in that case how can we get information of those referenced files i-e their names. also does opendwg opens the referenced files itself or do we have to open them by fetching their names and opening them manually.
basically what i am trying to do is to read a dwg file and convert all the geometric information into a mesh. this work has been done in gl based examples that come with dwg. however they are using the vectorization libraries provided by dwg. i can't get to access the rendering code, where each object is converted to vertex and face information, that in turn is used for the purpose of rendering. so is there a way i can access the code, where the geometric data of different objects is being extracted using dwg.
regards.
hi,
i can help you with questions 2) and 3).
2) see odavematerial class doc. there you have a static method odavematerial::getattachedmaterial(). you should pass the relevant objectid as an input param, and the method will return as a ref parameter the material objectid. after that you should use another static method odavematerial::getmaterial() and to pass the material objectid. that method will return you odavematerialptr(smart pointer). then you can use the relevant methods of the odavematerialclass to get the material properties as diffuse color, roughness etc.
3) there is an example how to get the scene lights.
see \dwgdirect_folder\source\examples\odaveex example.
dbavedumper.cpp consists the code for that.
hi nino !
thankyou so much. that really helped. now am left with 1 and 4
regards.
hi trivor,
quote:
1) how can we identify the type of solid once its read i-e if its a sphere, wedge, box or even some arbitrarily extruded / revolved solid. i basically need the vertex / face information for all sorts of objects. so if there is a way of getting that information without identifying the type of object, that will do as well. i know that one way will be to repeatedly explode the objects until we are left with basic primitives such as lines/arcs. but i am sure there will be a better way of doing it.
you should explore the odbr classes (brep library) if you want to extract the geometry of oddb3dsolid entities.
quote:
4) we know that different files are referenced by a given dwg file. in that case how can we get information of those referenced files i-e their names. also does opendwg opens the referenced files itself or do we have to open them by fetching their names and opening them manually.
best regards
chudomir
sorry my reply was not finished:
quote:
4) we know that different files are referenced by a given dwg file. in that case how can we get information of those referenced files i-e their names. also does opendwg opens the referenced files itself or do we have to open them by fetching their names and opening them manually.
i suppose you mean external references.
they are stored in the oddbblocktable as oddbblocktablerecord objects. you can access the entities there without need to open the referenced files with additional code. these external blocks are referenced from oddbblockreference entities.
however, you have different records in the block table (like model space, paper spaces, other blocks). you can iterate the block table and check each block with the functions oddbblocktablerecord::isfromexternalreference() and oddbblocktablerecord::isfromoverlayreference(). if one of these functions returns true (you should check them both) then you can call oddbblocktablerecord:athname() to get the file name if you need it.
but opening the block and iterating the entities there should be enough to get the information i believe.
best regards
chudomir
quote:
basically what i am trying to do is to read a dwg file and convert all the geometric information into a mesh
i may be wrong but i have a feeling that the proper way here surely would be to use the rendering code of dwgdirect - in fact the dwgdirect guys had done big big work on that and i don't know whether you'd have the time resource to process all the dwg file structure...
if you want to get meshes, then you can inherit from odgsbasevectorizedevice and odgsbasevectorizeview and use the virtual functions there - like line, circle, mesh, spline etc. they will explode the 3dsolids to faces, splines to lines, etc. you don't need to use their opengl code, because you need the geometry. after collecting the geometry you can get into your own rendering machine if you need to display the drawing.
as to materials and lights, nino has replied and i don't think you'll have big problems with them - beware that they are not part of the odgs classes and odgs should be used to retrieve the geometry only.
best regards
chudomir
hi !
thanks chudo. i looked into the odbr classes and i can get the vertice / face information on 3dsolids, bodies and regions using these libraries. for other primitives i can simply get their geometric information such as radius, angles etc for arcs and generate vertices using this information. please correct me if i there is some other better way of getting the vertice/face information of various primitives of autocad.
[quote]
if you want to get meshes, then you can inherit from odgsbasevectorizedevice and odgsbasevectorizeview and use the virtual functions there - like line, circle, mesh, spline etc. they will explode the 3dsolids to faces, splines to lines, etc. you don't need to use their opengl code, because you need the geometry. after collecting the geometry you can get into your own rendering machine if you need to display the drawing.
[\quote]
thats exactly what i want to do. but i am confused as to how can inheriting from odgsbasevectorize class will help me get the mesh information. also is there some way i can access the code for the vectorization classes of opendwg.
regards.
last edited by trivor; 7th june 2005 at 01:28 amfff">.
hi,
there should be the class exgigdigeometry and exgsgdivectorizedevice in the examples somewhere - at least i think they were there in the previous dwgdirect versions.
i'm not sure how you can get mesh information for example from arc or circle, but in general you can use most of the functions coming from odgigeometrysimplifier:
void plineproc(const odgipolyline& lwbuf,
const odgematrix3d* pxform = 0,
oduint32 fromindex = 0,
oduint32 numsegs = 0);
void polylineproc(odint32 nbpoints,
const odgepoint3d* pvertexlist,
const odgevector3d* pnormal = 0,
const odgevector3d* pextrusion = 0,
odint32 lbasesubentmarker = -1);
void polygonproc(odint32 nbpoints,
const odgepoint3d* pvertexlist,
const odgevector3d* pnormal = 0,
const odgevector3d* pextrusion = 0);
void xlineproc(const odgepoint3d&, const odgepoint3d&);
void rayproc(const odgepoint3d&, const odgepoint3d&);
void meshproc(odint32 rows,
odint32 columns,
const odgepoint3d* pvertexlist,
const odgiedgedata* pedgedata = 0,
const odgifacedata* pfacedata = 0,
const odgivertexdata* pvertexdata = 0);
void shellproc(odint32 nbvertex,
const odgepoint3d* pvertexlist,
odint32 facelistsize,
const odint32* pfacelist,
const odgiedgedata* pedgedata = 0,
const odgifacedata* pfacedata = 0,
const odgivertexdata* pvertexdata = 0);
virtual void shellfaceout(odint32 facelistsize,
const odint32* pfacelist,
const odgevector3d* pnormal);
virtual void triangleout(const odint32* p3vertices,
const odgevector3d* pnormal);
virtual void facetout(const odint32* pfacelist,
const odint32* pedgeindices,
const odgevector3d* pnormal);
void circleproc(const odgepoint3d& center,
double radius,
const odgevector3d& normal,
const odgevector3d* pextrusion = 0);
void circleproc(const odgepoint3d& start,
const odgepoint3d& point,
const odgepoint3d& end,
const odgevector3d* pextrusion = 0);
void circulararcproc(const odgepoint3d& center,
double radius,
const odgevector3d& normal,
const odgevector3d& startvector,
double sweepangle,
odgiarctype arctype = kodgiarcsimple,
const odgevector3d* pextrusion = 0);
void circulararcproc(const odgepoint3d& start,
const odgepoint3d& point,
const odgepoint3d& end,
odgiarctype arctype = kodgiarcsimple,
const odgevector3d* pextrusion = 0);
void textproc(const odgepoint3d& position,
const odgevector3d& u,
const odgevector3d& v,
const odchar* msg,
odint32 length,
bool raw,
const odgitextstyle* ptextstyle,
const odgevector3d* pextrusion = 0);
void shapeproc(const odgepoint3d& position,
const odgevector3d& u,
const odgevector3d& v,
int shapeno,
const odgitextstyle* pstyle,
const odgevector3d* pextrusion = 0);
void nurbsproc(const odgenurbcurve3d& nurbs);
void elliparcproc(
const odgeelliparc3d& elliparc,
const odgepoint3d* pendpointsoverrides = 0,
odgiarctype arctype = kodgiarcsimple,
const odgevector3d* pextrusion = 0);
you should override the functions you want and collect the geometry.
hope this helps.
best regards
chudomir
odvectorizeex example illustrates obtaining geometry information from dwg drawing.
it reads in dwg (dxf) file and dumps geometry in text form.
sergey slezkin
quote:
originally posted by sergey slezkin
odvectorizeex example illustrates obtaining geometry information from dwg drawing.
it reads in dwg (dxf) file and dumps geometry in text form.
hi !
thanks sergey, it really helped. i looked into the odvectorize example and molded it according to my needs. however i am again stuck with an issue. i do not get the mesh information, instead i get the primitive based information of objects. for instance, if i am reading a pipe (represented as a 3dsolid), the vectorization will explode it and return four polylines and two ellipsoids, and then the points that make up these lines and ellipsis. however i need the information on faces and vertices that formed the pipe (in other words the polygonized data of pipe and not the points that made up the primitives who formed the pipe).
please can you tell me as to how can i get face / vertex information of such objects.
regards.
3dsolid objects are rendered differently as meshes, wireframe or both depending on regen mode of viewport they are rendered through. if regen mode is 2d-optimized or 3d-wireframe you get wireframe, if "shaded" etc. - you get mesh.
file attached contains single sphere in model space. where are 2 *active viewports in it - one is 2d-optimized, another - shaded.
odvectorizeex dumps the same sphere twice as wireframe for the first viewport and as mesh for the second one.
attached files (108.9 kb, 13 views)

sergey slezkin
hi sergey !
thank you so much. yea it really worked that way. but is there some way i can get the mesh information even if the viewport render mode is set to 2d or 3d wireframe ?
regards.
how a 3dsolid is rendered depends on value of render mode returned by odgsview::mode().
in odvectorizeex sample oddbgsmanager::setupactivelayoutviews() creates gsviews in device for active layout. it sets their parameters accordingly to oddbviewport entities in paper space or accordingly to *active oddbviewporttablerecords for model space layout.
btw, if you need convert single 3dsolid to mesh you can use decomposeforsave() function.
sergey slezkin
hi !
thanks every one. it really helped. i am now able to get the geometry related information needed to regenerate the model. the next step is to read apply materials on the model. for the purpose i need to know the texture coordinate associated with each vertex. please can someone tell me as to how can i fetch this information using opendwg.
regards.
hi !
i am also unable to read the solid in the attatched dwg file. can anyone tell me what can be the possible reason.
regards.
attached files (700.2 kb, 17 views)
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】acis 3d solids questions yang686526 DirectDWG 0 2009-05-04 03:36 PM
【转帖】some basic questions yang686526 SolidWorks二次开发 0 2009-04-13 02:36 PM
there are three terrible questions on SW translator as below huangyhg SolidWorks二次开发 3 2007-09-04 01:38 PM


所有的时间均为北京时间。 现在的时间是 07:06 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多