[cgma-dev] r2276 - cgm/trunk/geom/OCC
Tim Tautges
tautges at mcs.anl.gov
Thu Nov 20 15:21:36 CST 2008
Jane,
Good job, this sort of support is very important to the "big picture".
- tim
janehu at mcs.anl.gov wrote:
> Author: janehu
> Date: 2008-11-20 15:17:58 -0600 (Thu, 20 Nov 2008)
> New Revision: 2276
>
> Modified:
> cgm/trunk/geom/OCC/OCCDrawTool.cpp
> cgm/trunk/geom/OCC/OCCQueryEngine.cpp
> cgm/trunk/geom/OCC/OCCQueryEngine.hpp
> Log:
> Partial fix for user reported error in OCCDrawTool, and some minor changes.
>
> Modified: cgm/trunk/geom/OCC/OCCDrawTool.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCDrawTool.cpp 2008-11-19 19:06:22 UTC (rev 2275)
> +++ cgm/trunk/geom/OCC/OCCDrawTool.cpp 2008-11-20 21:17:58 UTC (rev 2276)
> @@ -70,7 +70,7 @@
> for (ii=1; ii<=M.Extent(); ii++)
> {
> TopologyBridge *face = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
> - OCCSurface *occ_face = CAST_TO(occ_face, OCCSurface);
> + OCCSurface *occ_face = CAST_TO(face, OCCSurface);
> Face_list.append_unique(occ_face->get_TopoDS_Face());
> }
> int i;
> @@ -181,6 +181,9 @@
> GMem g_mem;
> int num_points;
> OCCQueryEngine *OQE = OCCQueryEngine::instance();
> + double tol = OQE->get_sme_resabs_tolerance();
> + if (curve->get_arc_length() < tol)
> + return CUBIT_SUCCESS;
> // get the graphics
> CubitStatus stat;
> stat = OQE->get_graphics( curve, num_points, &g_mem );
>
> Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-11-19 19:06:22 UTC (rev 2275)
> +++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-11-20 21:17:58 UTC (rev 2276)
> @@ -31,8 +31,11 @@
> #include "Poly_Triangle.hxx"
> #include "BRepAlgoAPI_BooleanOperation.hxx"
> #include "Handle_Poly_Triangulation.hxx"
> +#include "BRepAdaptor_Curve.hxx"
> +#include "BndLib_Add3dCurve.hxx"
> #include "Poly_Polygon3D.hxx"
> #include "Handle_Poly_Polygon3D.hxx"
> +#include "BRepMesh_FastDiscret.hxx"
> #include "OCCQueryEngine.hpp"
> #include "OCCModifyEngine.hpp"
> #include "Poly_Triangulation.hxx"
> @@ -269,15 +272,32 @@
> TopLoc_Location L;
> Handle_Poly_Triangulation facets = BRep_Tool::Triangulation(*Topo_Face, L);
>
> + if(facets.IsNull())
> + {
> + //do triangulation
> + double deflection = 0.01;
> + double angle = 0.5;
> + BRepAdaptor_Surface asurface(*Topo_Face);
> + Bnd_Box aBox;
> + BndLib_AddSurface::Add(asurface, Precision::Approximation(), aBox);
> + BRepMesh_FastDiscret *myMesh =
> + new BRepMesh_FastDiscret(deflection, *Topo_Face, aBox, angle, Standard_True, Standard_True);
> + if (myMesh != NULL) delete myMesh;
> + facets = BRep_Tool::Triangulation(*Topo_Face, L);
> + if(facets.IsNull())
> + {
> + PRINT_ERROR("Can't get triangulation representation for this surface.\n");
> + return CUBIT_FAILURE;
> + }
> + }
> //if necessary, the face tolerance can be returned. now, no use.
> //double tol = BRep_Tool::Tolerance(*Topo_Face);
>
> number_points = facets->NbNodes();
> number_triangles = facets->NbTriangles();
> - assert(number_points == 3 * number_triangles);
> number_facets = 4 * number_triangles;
>
> - Poly_Array1OfTriangle triangles(0, number_facets-1);
> + Poly_Array1OfTriangle triangles(0, number_triangles-1);
> triangles.Assign( facets->Triangles() );
> int *facetList = new int[number_facets];
> //needs to test that N1, N2, N3 index are starting from 0 to number_points-1
> @@ -337,20 +357,28 @@
> if (!Topo_Edge)
> return CUBIT_FAILURE;
>
> - TopLoc_Location L;
> - Handle_Poly_Polygon3D facets = BRep_Tool::Polygon3D(*Topo_Edge, L);
> + //do triangulation
> + double deflection = 0.01;
> + double angle = 0.5;
> + BRepAdaptor_Curve acurve(*Topo_Edge);
> + Bnd_Box aBox;
> + BndLib_Add3dCurve::Add(acurve, Precision::Approximation(), aBox);
> + BRepMesh_FastDiscret *myMesh =
> + new BRepMesh_FastDiscret(deflection, *Topo_Edge, aBox, angle, Standard_True, Standard_True);
> + if (myMesh == NULL)
> + {
> + PRINT_ERROR("Can't get triangulation representation for this curve.\n");
> + return CUBIT_FAILURE;
> + }
> + num_points = myMesh->NbVertices();
>
> - num_points = facets->NbNodes();
> - TColgp_Array1OfPnt points(0, num_points-1);
> - points.Assign(facets->Nodes());
> -
> //! Note: If the polygon is closed, the point of closure is
> //! repeated at the end of its table of nodes. Thus, on a closed
> //! triangle the function NbNodes returns 4.
> GPoint *gPnts= new GPoint[num_points];
> - for (int i = 0; i < num_points ; i ++)
> + for (int i = 1; i <= num_points ; i ++)
> {
> - gp_Pnt gp_pnt = points.Value(i);
> + gp_Pnt gp_pnt = myMesh->Pnt(i);
> GPoint gPnt;
> gPnt.x = gp_pnt.X();
> gPnt.y = gp_pnt.Y();
> @@ -359,6 +387,7 @@
> }
> gMem->replace_point_list( gPnts, num_points, num_points );
>
> + delete myMesh;
> return CUBIT_SUCCESS;
> }
>
> @@ -1871,7 +1900,7 @@
> // Creation Date : 12/12/07
> //-------------------------------------------------------------------------
> CubitStatus
> -OCCQueryEngine::unhook_CoFaces_from_OCC( DLIList<OCCCoFace*> cofaces) const
> +OCCQueryEngine::unhook_CoFaces_from_OCC( DLIList<OCCCoFace*>& cofaces) const
> {
> int size = cofaces.size();
> while(size > 0)
> @@ -2051,7 +2080,7 @@
> // Creation Date : 12/12/07
> //-------------------------------------------------------------------------
> CubitStatus
> -OCCQueryEngine::unhook_CoEdges_from_OCC( DLIList<OCCCoEdge*> coedges) const
> +OCCQueryEngine::unhook_CoEdges_from_OCC( DLIList<OCCCoEdge*>& coedges) const
> {
> int size = coedges.size();
> while(size > 0)
>
> Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
> ===================================================================
> --- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-11-19 19:06:22 UTC (rev 2275)
> +++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-11-20 21:17:58 UTC (rev 2276)
> @@ -274,8 +274,8 @@
>
> CubitStatus unhook_Lump_from_OCC( Lump* lump ) const;
> CubitStatus unhook_ShellSM_from_OCC( ShellSM* shell ) const;
> - CubitStatus unhook_CoEdges_from_OCC( DLIList<OCCCoEdge*> coedges) const;
> - CubitStatus unhook_CoFaces_from_OCC( DLIList<OCCCoFace*> cofaces) const;
> + CubitStatus unhook_CoEdges_from_OCC( DLIList<OCCCoEdge*>& coedges) const;
> + CubitStatus unhook_CoFaces_from_OCC( DLIList<OCCCoFace*>& cofaces) const;
> CubitStatus unhook_LoopSM_from_OCC( LoopSM* loopsm) const;
> CubitStatus delete_loop( LoopSM* loopsm)const;
> void unhook_cofaces_of_a_surface(OCCSurface* surface)const;
>
>
--
================================================================
"You will keep in perfect peace him whose mind is
steadfast, because he trusts in you." Isaiah 26:3
Tim Tautges Argonne National Laboratory
(tautges at mcs.anl.gov) (telecommuting from UW-Madison)
phone: (608) 263-8485 1500 Engineering Dr.
fax: (608) 263-4499 Madison, WI 53706
More information about the cgma-dev
mailing list