[cgma-dev] r1404 - cgm/trunk/geom/OCC
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Fri Nov 16 12:29:53 CST 2007
Author: janehu
Date: 2007-11-16 12:29:53 -0600 (Fri, 16 Nov 2007)
New Revision: 1404
Modified:
cgm/trunk/geom/OCC/OCCBody.hpp
cgm/trunk/geom/OCC/OCCCurve.cpp
cgm/trunk/geom/OCC/OCCCurve.hpp
cgm/trunk/geom/OCC/OCCModifyEngine.hpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.hpp
cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
Added G1_discontinuity and get_point_direction in OCCCurve,ve; changed import and export shape file.
Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp 2007-11-16 18:15:21 UTC (rev 1403)
+++ cgm/trunk/geom/OCC/OCCBody.hpp 2007-11-16 18:29:53 UTC (rev 1404)
@@ -203,9 +203,10 @@
OCCAttribSet attribSet;
//List of OCCAttrib*'s instead of CubitSimpleAttribs
TopoDS_Shape *myTopoDSShape;
-};
CubitBox boundingbox;
+};
+
#endif
Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp 2007-11-16 18:15:21 UTC (rev 1403)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp 2007-11-16 18:29:53 UTC (rev 1404)
@@ -590,19 +590,35 @@
//-------------------------------------------------------------------------
// Purpose : Return direction of point on curve
//
-// Special Notes : not currently implemented
+// Special Notes : Finds the underlying line's origin and direction unit vector
//
-// Creator : Steve Owen
+// Creator : Jane Hu
//
-// Creation Date : 07/14/00
+// Creation Date : 11/14/07
//-------------------------------------------------------------------------
CubitStatus OCCCurve::get_point_direction( CubitVector& point,
- CubitVector& direction )
+ CubitVector& direction )
{
- point = point;
- direction = direction;
- PRINT_DEBUG_122("OCCCurve::get_point_direction currently not implemented.\n");
- return CUBIT_FAILURE;
+ if (geometry_type() != STRAIGHT_CURVE_TYPE)
+ return CUBIT_FAILURE;
+
+ //get the underlying geometry curve
+ double first,last;
+ Handle(Geom_Curve) gCurve = BRep_Tool::Curve(*myTopoDSEdge, first, last);
+
+ //get the origin and direction of the underlying curve
+ Handle(Geom_Line) gLine = Handle(Geom_Line)::DownCast(gCurve);
+ gp_Ax1 axis = gLine->Position();
+ gp_Pnt loc = axis.Location();
+ gp_Dir dir = axis.Direction();
+ point.set(loc.X(), loc.Y(), loc.Z());
+
+ //Based on the TopoDS_Edge's orientation, give the unit vector.
+ if (myTopoDSEdge->Orientation() == TopAbs_FORWARD)
+ direction.set(dir.X(), dir.Y(), dir.Z());
+ else if(myTopoDSEdge->Orientation() == TopAbs_REVERSED)
+ direction.set(-dir.X(), -dir.Y(), -dir.Z());
+
}
//-------------------------------------------------------------------------
@@ -731,7 +747,7 @@
void OCCCurve::get_parents_virt( DLIList<TopologyBridge*>& parents )
- { /*CAST_LIST_TO_PARENT( myCoEdges, parents ); */}
+ { CAST_LIST_TO_PARENT( myCoEdges, parents ); }
void OCCCurve::get_children_virt( DLIList<TopologyBridge*>& children )
{
TopTools_IndexedMapOfShape M;
@@ -764,16 +780,33 @@
//-------------------------------------------------------------------------
// Purpose : Check for G1 discontinuity
//
-// Special Notes : not implemented
+// Special Notes : returns tangency discontinuity all along the Curve
+// at the param, only returns minus tangent = plus tangent
+// when it's C1 continuity.
//
-// Creator : Steve Owen
+// Creator : Jane Hu
//
-// Creation Date : 07/14/00
+// Creation Date : 11/14/07
//-------------------------------------------------------------------------
CubitBoolean OCCCurve::G1_discontinuous(
double param, CubitVector* mtan, CubitVector* ptan )
{
- assert(0);
+ CubitBoolean is_discon = CUBIT_TRUE;
+ double first, last;
+ Handle(Geom_Curve) gCurve = BRep_Tool::Curve(*myTopoDSEdge, first, last);
+
+ if (gCurve->Continuity() < GeomAbs_G1)
+ return is_discon;
+
+ assert(first <= param <= last );
+
+ gp_Pnt P;
+ gp_Vec V1;
+ gCurve->D1(param, P, V1);
+
+ mtan = new CubitVector(V1.X(), V1.Y(),V1.Z());
+ ptan = new CubitVector(*mtan);
+
return CUBIT_FALSE;
}
@@ -835,6 +868,14 @@
}
}
+void OCCCurve::get_coedges( DLIList<OCCCoEdge*>& result_list )
+{
+ myCoEdges.reset();
+ for ( int i = 0; i < myCoEdges.size(); i++ )
+ if ( OCCCoEdge* coedge = dynamic_cast<OCCCoEdge*>(myCoEdges.next(i)) )
+ result_list.append(coedge);
+}
+
void OCCCurve::get_points( DLIList<OCCPoint*>& result_list )
{
TopTools_IndexedMapOfShape M;
@@ -891,8 +932,40 @@
{
return CUBIT_PNT_UNKNOWN;
}
+CubitPointContainment OCCCurve::point_containment( double /*u_param*/,
+ double /*v_param*/ )
+{
+ return CUBIT_PNT_UNKNOWN;
+}
+CubitPointContainment OCCCurve::point_containment( CubitVector &/*point*/,
+ double /*u_param*/,
+ double /*v_param*/ )
+{
+ return CUBIT_PNT_UNKNOWN;
+}
+//-------------------------------------------------------------------------
+// Purpose : Tear down topology
+//
+// Special Notes :
+//
+// Creator : Jason Kraftcheck
+//
+// Creation Date : 09/29/03
+//-------------------------------------------------------------------------
+CubitStatus OCCCurve::disconnect_coedge( OCCCoEdge* coedge )
+{
+ assert(0);
+ if (!myCoEdges.move_to(coedge))
+ return CUBIT_FAILURE;
+ myCoEdges.remove();
+ assert(coedge->curve() == this);
+ coedge->remove_curve();
+
+ return CUBIT_SUCCESS;
+}
+
// ********** END PRIVATE FUNCTIONS **********
// ********** BEGIN HELPER CLASSES **********
Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp 2007-11-16 18:15:21 UTC (rev 1403)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp 2007-11-16 18:29:53 UTC (rev 1404)
@@ -12,8 +12,8 @@
// Owner : Steven J. Owen
//-------------------------------------------------------------------------
-#ifndef CURVE_FACET_HPP
-#define CURVE_FACET_HPP
+#ifndef CURVE_OCC_HPP
+#define CURVE_OCC_HPP
// ********** BEGIN STANDARD INCLUDES **********
// ********** END STANDARD INCLUDES **********
@@ -345,6 +345,14 @@
TopoDS_Edge *get_TopoDS_Edge( )
{ return myTopoDSEdge; }
+ void add_loop( LoopSM *loop_ptr )
+ { myLoops.append_unique( loop_ptr ); }
+ //- associate this curve with a coedge
+
+ void add_coedge( CoEdgeSM *coedge_ptr )
+ { myCoEdges.append_unique( coedge_ptr ); }
+ //- associate this curve with a coedge
+
Point *start_point()
{ assert(0);return myStartPoint; }
Point *end_point()
@@ -356,6 +364,7 @@
void remove_start_point() { myStartPoint = 0; }
void remove_end_point() { myEndPoint = 0; }
+ bool has_parent_coedge() { return myCoEdges.size() > 0; }
protected:
@@ -384,8 +393,10 @@
friend void run_test_function();
TopoDS_Edge *myTopoDSEdge;
+ DLIList<LoopSM*> myLoops;
Point *myStartPoint;
Point *myEndPoint;
+ DLIList<CoEdgeSM*> myCoEdges;
int myId;
bool periodic;
};
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2007-11-16 18:15:21 UTC (rev 1403)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2007-11-16 18:29:53 UTC (rev 1404)
@@ -55,7 +55,6 @@
static OCCModifyEngine* instance_;
public:
-
static inline OCCModifyEngine* instance()
{
if( !instance_ )
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2007-11-16 18:15:21 UTC (rev 1403)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2007-11-16 18:29:53 UTC (rev 1404)
@@ -106,16 +106,16 @@
OCCQueryEngine* OCCQueryEngine::instance_ = NULL;
const int OCCQueryEngine::OCCQE_MAJOR_VERSION = 6;
-const int OCCQueryEngine::OCCQE_MINOR_VERSION = 1;
+const int OCCQueryEngine::OCCQE_MINOR_VERSION = 2;
const int OCCQueryEngine::OCCQE_SUBMINOR_VERSION = 0;
TopTools_DataMapOfShapeInteger *OCCQueryEngine::OCCMap = new TopTools_DataMapOfShapeInteger;
TopTools_DataMapOfShapeInteger *OCCQueryEngine::OCCMapr = new TopTools_DataMapOfShapeInteger;
DLIList<TopologyBridge*> *OCCQueryEngine::CGMList = new DLIList<TopologyBridge*>;
-std::map<int, TopologyBridge*>* OccToCGM = new std::map<int, TopologyBridge*>;
+std::map<int, TopologyBridge*>* OCCQueryEngine::OccToCGM = new std::map<int, TopologyBridge*>;
typedef std::map<int, TopologyBridge*>::value_type valType;
-int iTotalTBCreated = 0;
+int OCCQueryEngine::iTotalTBCreated = 0;
CubitBoolean PRINT_RESULT = CUBIT_FALSE;
//================================================================================
// Description:
@@ -770,8 +770,8 @@
//Function Name:export_solid_model
//Member Type: PUBLIC
//Description: function called for save/restore to save temporary FACET file
-//Author: Corey Ernst
-//Date: 1/18/2003
+//Author: Jane Hu
+//Date: 11/16/2007
//===========================================================================
CubitStatus OCCQueryEngine::export_solid_model( DLIList<TopologyBridge*>& ref_entity_list,
@@ -842,30 +842,11 @@
free_curve_count == 0 && free_point_count == 0)
return CUBIT_SUCCESS;
- //get file pointer
- FILE *file_ptr = fopen( file_name, "wb" );
-
- //create a wrapper object for writing
- CIOWrapper file_writer( file_ptr );
-
- // write out file type "OCC_BASED_GEOMETRY"
- file_writer.BeginWriteBlock(0);
- file_writer.Write( "OCC_BASED_GEOMETRY", 19 );
-
- // write out Endian value
- UnsignedInt32 endian_value = CCubitFile::mintNativeEndian;
- file_writer.Write( &endian_value, 1 );
-
- // write out version #
- UnsignedInt32 version = 1;
- file_writer.Write( &version, 1 );
-
-
//save the facets (geometry info )
CubitStatus status;
//write out topology and attributes
- status = write_topology( file_ptr,
+ status = write_topology( file_name,
OCC_bodies, OCC_surfaces,
OCC_curves, OCC_points );
if( status == CUBIT_FAILURE ) return CUBIT_FAILURE;
@@ -916,17 +897,15 @@
}
PRINT_INFO( "\n" );
- fclose( file_ptr );
-
return CUBIT_SUCCESS;
}
CubitStatus
-OCCQueryEngine::write_topology( FILE *file_ptr,
- DLIList<OCCBody*> &OCC_bodies,
- DLIList<OCCSurface*> &OCC_surfaces,
- DLIList<OCCCurve*> &OCC_curves,
- DLIList<OCCPoint*> &OCC_points )
+OCCQueryEngine::write_topology( const char* file_name,
+ DLIList<OCCBody*> &OCC_bodies,
+ DLIList<OCCSurface*> &OCC_surfaces,
+ DLIList<OCCCurve*> &OCC_curves,
+ DLIList<OCCPoint*> &OCC_points )
{
int i;
@@ -959,8 +938,11 @@
TopoDS_Vertex *vertex = OCC_points.get_and_step()->get_TopoDS_Vertex();
B.Add(Co, *vertex);
}
-
- if(!BRepTools::Write(Co, (char *) file_ptr))
+
+ char* file = new char[sizeof(file_name)];
+ strcpy(file, file_name);
+
+ if(!BRepTools::Write(Co, file))
return CUBIT_FAILURE;
return CUBIT_SUCCESS;
@@ -969,13 +951,13 @@
CubitStatus
OCCQueryEngine::import_temp_geom_file(FILE* file_ptr,
- const char* /*file_name*/,
- const char* file_type,
- DLIList<TopologyBridge*> &bridge_list )
+ const char* file_name,
+ const char* file_type,
+ DLIList<TopologyBridge*> &bridge_list )
{
//make sure that file_type == "OCC"
if( !strcmp( file_type,"OCC") )
- return import_solid_model( file_ptr, file_type, bridge_list );
+ return import_solid_model( file_name, file_type, bridge_list );
else
return CUBIT_FAILURE;
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2007-11-16 18:15:21 UTC (rev 1403)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2007-11-16 18:29:53 UTC (rev 1404)
@@ -335,7 +335,7 @@
OCCLoop* populate_topology_bridge(TopoDS_Wire aShape);
OCCShell* populate_topology_bridge(TopoDS_Shell aShape);
- CubitStatus write_topology( FILE *file_ptr,
+ CubitStatus write_topology( const char* file_name,
DLIList<OCCBody*> &facet_bodies,
DLIList<OCCSurface*> &facet_surfaces,
DLIList<OCCCurve*> &facet_curves,
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2007-11-16 18:15:21 UTC (rev 1403)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2007-11-16 18:29:53 UTC (rev 1404)
@@ -931,7 +931,6 @@
}
}
-
// ********** END PUBLIC FUNCTIONS **********
// ********** BEGIN PROTECTED FUNCTIONS **********
@@ -939,8 +938,8 @@
// ********** BEGIN PRIVATE FUNCTIONS **********
-//// void OCCSurface::reverse_sense()
-//// {
+void OCCSurface::reverse_sense()
+{
//// assert(0);
//// facetEvalTool->reverse_facets();
//// myLoops.reset();
@@ -966,7 +965,7 @@
//// //sense_ = CubitUtil::opposite_sense( sense_ );
//// myShellSense = CubitUtil::opposite_sense( myShellSense );
//// //myShellSense[1] = CubitUtil::opposite_sense( myShellSense[1] );
-//// }
+}
// ********** END PRIVATE FUNCTIONS **********
More information about the cgma-dev
mailing list