[cgma-dev] r1595 - in cgm/trunk: geom/OCC test
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Fri Feb 8 14:24:30 CST 2008
Author: janehu
Date: 2008-02-08 14:24:30 -0600 (Fri, 08 Feb 2008)
New Revision: 1595
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/test/makept.cpp
Log:
Added make_Surface for copy/extended options, created 'sheet' body, passed testing on copy, crashed on extended option.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-02-07 22:05:25 UTC (rev 1594)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-02-08 20:24:30 UTC (rev 1595)
@@ -20,6 +20,12 @@
#include "gp_Parab.hxx"
#include "gp_Elips.hxx"
#include "gp_Pln.hxx"
+#include "gp_Cylinder.hxx"
+#include "gp_Cone.hxx"
+#include "gp_Sphere.hxx"
+#include "gp_Torus.hxx"
+#include "BRepBuilderAPI_MakeShell.hxx"
+#include "BRepBuilderAPI_MakeSolid.hxx"
#include "TopoDS_Shape.hxx"
#include "TColgp_Array1OfPnt.hxx"
#include "GC_MakeArcOfCircle.hxx"
@@ -27,7 +33,6 @@
#include "GC_MakeArcOfParabola.hxx"
#include "GC_MakeArcOfEllipse.hxx"
#include "GC_MakeSegment.hxx"
-#include "GC_MakePlane.hxx"
#include "Geom_BezierCurve.hxx"
#include "Handle_Geom_Plane.hxx"
#include "BRepBuilderAPI_MakeEdge.hxx"
@@ -504,8 +509,20 @@
return (Surface *)NULL;
}
+ double UMax, VMax, UMin, VMin;
+ occ_surface->get_param_range_U(UMin, UMax);
+ occ_surface->get_param_range_V(VMin, VMax);
+
TopoDS_Face *theFace = occ_surface->get_TopoDS_Face();
+ if( !theFace)
+ {
+ PRINT_ERROR("Cannot create an OCC surface from the given surface.\n"
+ "Possible incompatible geometry engines.\n");
+ return (Surface *)NULL;
+ }
+
TopoDS_Face newFace;
+ BRepAdaptor_Surface asurface(*theFace);
if (extended_from == CUBIT_TRUE)
{
@@ -513,26 +530,41 @@
GeometryType type = occ_surface->geometry_type();
if (type == PLANE_SURFACE_TYPE)
{
- BRepAdaptor_Surface asurface(*theFace);
gp_Pln plane = asurface.Plane();
- Handle(Geom_Plane) gc_plane = GC_MakePlane(plane);
- newFace = BRepBuilderAPI_MakeFace(gc_plane);
+ newFace = BRepBuilderAPI_MakeFace(plane);
}
- else if(extended_from == CONE_SURFACE_TYPE)
+ else if(type == CONE_SURFACE_TYPE)
{
- //make a whole cone 2 times longer
+ //make an infinite cone.
+ //Given this lets create another face that is extended from it.
+ if(asurface.GetType() == GeomAbs_Cone)
+ {
+ gp_Cone cone = asurface.Cone();
+ newFace = BRepBuilderAPI_MakeFace(cone);
+ }
+ else
+ {
+ gp_Cylinder cylinder = asurface.Cylinder();
+ newFace = BRepBuilderAPI_MakeFace(cylinder);
+ }
}
- else if(extended_from == SPHERE_SURFACE_TYPE)
+ else if(type == SPHERE_SURFACE_TYPE)
{
//make a whole sphere.
+ gp_Sphere sphere = asurface.Sphere();
+ newFace = BRepBuilderAPI_MakeFace(sphere);
}
- else if(extended_from == TORUS_SURFACE_TYPE)
+ else if(type == TORUS_SURFACE_TYPE)
{
//make a whole torus
+ gp_Torus torus = asurface.Torus();
+ newFace = BRepBuilderAPI_MakeFace(torus);
}
- else if(extended_from == SPLINE_SURFACE_TYPE || BSPLINE_SURFACE_TYPE)
+ else if(type == SPLINE_SURFACE_TYPE )
{
//extend the surfaces using the equation if possible.
+ Handle(Geom_BezierSurface) bezier = asurface.Bezier();
+ newFace = BRepBuilderAPI_MakeFace(bezier);
}
}
@@ -541,8 +573,34 @@
TopoDS_Shape newShape = theFace->EmptyCopied();
newFace = TopoDS::Face(newShape);
}
- return OCCQueryEngine::instance()->populate_topology_bridge(newFace);
+
+ //populate the bridges from the body
+ Handle_Geom_Surface HGeom_surface = BRep_Tool::Surface(newFace);
+ TopoDS_Shell topo_shell;
+ if (extended_from == CUBIT_FALSE)
+ topo_shell = BRepBuilderAPI_MakeShell(HGeom_surface, UMin, UMax,
+ VMin, VMax);
+ else
+ topo_shell = BRepBuilderAPI_MakeShell(HGeom_surface);
+
+ TopoDS_Solid topo_solid = BRepBuilderAPI_MakeSolid(topo_shell);
+ Lump *lump =
+ OCCQueryEngine::instance()->populate_topology_bridge(topo_solid,
+ CUBIT_TRUE);
+
+ if (lump == NULL)
+ {
+ PRINT_ERROR("In AcisModifyEngine::make_Surface\n"
+ " Cannot make Surface object.\n");
+ return (Surface *)NULL;
+ }
+
+ DLIList<Surface*> surfs;
+ lump->surfaces( surfs );
+ Surface *surface = surfs.get();
+
+ return surface;
}
//===============================================================================
Modified: cgm/trunk/test/makept.cpp
===================================================================
--- cgm/trunk/test/makept.cpp 2008-02-07 22:05:25 UTC (rev 1594)
+++ cgm/trunk/test/makept.cpp 2008-02-08 20:24:30 UTC (rev 1595)
@@ -219,6 +219,24 @@
gti->ref_faces(ref_faces);
RefFace* ref_face = ref_faces.step_and_get();
+ //make a new refface out of existing refface.
+ RefFace* new_face = gmti->make_RefFace(ref_face);
+
+ bodies.clean_out();
+ gti->bodies(bodies);
+ //translate the new curve by (40,40,40)
+ for(int i = 1; i <= bodies.size(); i++)
+ {
+ bodies.step();
+ if( i != 4)
+ continue;
+ Body * entity = bodies.get();
+ gti->translate(entity, i*vector1);
+ }
+
+ vi = new_face->center_point();
+ //center point shout moved by (40,40,40) compared with the original one below
+
vi = ref_face->center_point();
// center point
@@ -289,6 +307,11 @@
double angle = edge1->angle_between(edge2, ref_face);
//test for curve
+ for (int j = free_entities.size(); j--;)
+ {
+ gti->delete_RefEntity( free_entities.get_and_step());
+ }
+
DLIList<RefEdge *> ref_edges;
gti->ref_edges(ref_edges);
@@ -299,18 +322,16 @@
free_entities.clean_out();
gti->get_free_ref_entities(free_entities);
- //translate the new curve by (30,30,30)
- for(int i = 1; i <= free_entities.size(); i++)
- {
- if( i != 3)
- continue;
- RefEntity * entity = free_entities.get_and_step();
- gti->translate((BasicTopologyEntity*)entity, i*vector1);
- }
+ //translate the new curve by (10,10,10)
+ RefEntity * entity = free_entities.get();
+ gti->translate((BasicTopologyEntity*)entity, vector1);
+
box = new_edge->get_curve_ptr()->bounding_box();
// test free curve translation
+ box = ref_edge->get_curve_ptr()->bounding_box();
+
DLIList<OCCCurve*> curves;
CAST_TO(body, OCCBody)->get_all_curves(curves);
More information about the cgma-dev
mailing list