You are on page 1of 115

Rapidform.

dll Tutorial
INUS Technology, Inc.
Contents
Overview
Visual C++ environment setting
Basic definition
Entity interfaces
Primitives
Geometric calculation APIs
Command APIs
Display
Selection
OVERVIEW
Overview
Architecture
Single model support
Internal unit: millimeters[mm], radian[radian]
Primitive object
Kernel DB
Command APIs
Kernel DB Interfaces
RFCmdFileIOAPI, RFCmdPolygonAPI,
CINSPoint, CINSVector, CINSPlane,
IRFModel, IRFFeature, IRFShell,
Application
Rapidform.dll
Geometric Calculation APIs
INSCGAPI, CINSLSQFitAPI,
Entities of RAPIDFORM
Overview
Model
Curve
Surface
Shell
Vertex
Face
Curve
Surface
Work Process
Overview
Point clouds or meshes
Pre-process
Align
Generate mesh
Post-process
Generate Curve
Generate Surface
Calculate deviation
Polygon
VISUAL C++ ENVIRONMENT
SETTING
Visual C++ Environment Setting
Built in Microsoft Visual C++ 2003(VC71) and 2005(VC80)
Specify Additional Include Directories
Installed directory\Rapidform Library\Include
Ex) C:\Program Files\INUS Technology\Rapidform.dll\Rapidform Library\Include
Specify Additional Library Directories
Installed directory\Rapidform Library\Lib\VC71
Installed directory\Rapidform Library\Lib\VC80
Ex) C:\Program Files\INUS Technology\Rapidform.dll\Rapidform Library\Lib\VC71
Ex) C:\Program Files\INUS Technology\Rapidform.dll\Rapidform Library\Lib\VC80
Specify Additional Dependencies
Add RapiformDev.lib for evaluation version
Add Rapidform.lib for license free released version
Copy installed DLLs to where your execute file exists
Installed directory\Rapidform Library\Dll\VC71
Installed directory\Rapidform Library\Dll\VC80
Visual C++ Environment Setting
Specify Additional Include Directories
Visual C++ Environment Setting
Specify Additional Library Directories
Visual C++ Environment Setting
Specify Additional Dependencies
Visual C++ Environment Setting
Specify Struct Member Alignment
Visual C++ Environment Setting
Specify Character Set
Visual C++ Environment Setting
Specify Runtime Library
Visual C++ Environment Setting
Exercise
Build your APITest project
@ Installed directory\Example Application\APITest\APITest_VC71.sln
BASIC DEFINITION
Basic Definition
INSStatus
Return value of low level APIs and kernel entitys interface
typedef long INSStatus;
INSERROR_OK
0; No error occurs.
INSERROR_WARN
1; Warning error occurs. That is ignorable.
INSERROR_SEVERE
2; Severe error occurs. The function can't continue.
INSERROR_FATAL
3; Fatal error occurs. The application can't continue.
Basic Definition
eRFErrorCode
Return value of command API
RF_SUCCESS is returned if there is no error.
RF_SUCCESS=0, //!<Noerroroccurs.
RF_ERROR_UNKNOWN=1, //!<Unknownerroroccurs.
RF_ERROR_USERBREAK, //!<Userbreak.
RF_ERROR_OUT_OF_MEMORY, //!<Outofmemoryerroroccurs.
RF_ERROR_INVALID_RFMODEL, //!<ThemodelIDisinvalid.
RF_ERROR_INVALID_ENTITY_ID, //!<TheentityIDisinvalid.
...
RF_ERROR_END
Basic Definition
INSEntityID
The unique kernel entity ID class
Three low-level IDs and entity type.
Each kernel entity is identified by an entity ID.
Entity ID is not retained over file I/O operations.
Entity interfaces provide SetID() method to specify an individual entity.
Entity interfaces provide Assert() method to check the validation of ID
typedef unsignedlongINSID;
typedef enum{
ENTITY_UNDEFINED=0,
ENTITY_MODEL,
ENTITY_SHELL,
ENTITY_FACE,
ENTITY_EDGEUSE,
ENTITY_VERTEX,
ENTITY_CURVE,
ENTITY_SURFACE,
}INSEntityType;
classINSEntityID
{
INSID m_ID1;
INSID m_ID2;
INSID m_ID3;
INSEntityType m_Type;
};
Basic Definition
INSEntityID
Type(m_Type) OwnerID(m_ID1) LowID(m_ID2) AuxID(m_ID3)
ENTITY_MODEL ModelID ModelID
ENTITY_SHELL ModelID ShellID
ENTITY_FACE ShellID FaceID
ENTITY_VERTEX ShellID VertexID
ENTITY_EDGEUSE LeftFaceID StartVertexID EndVertexID
ENTITY_CURVE ModelID CurveID
ENTITY_SURFACE ModelID SurfaceID
<EDGEUSE >
StartVertex
EndVertex
StartVertex
EndVertex
LeftFace
LeftFace
ENTITY INTERFACES
Entity Interfaces
IRFEntity
IRFModel
IRFShell
IRFFace
IRFVertex
IRFEdgeUse
IRFBSplineCurve
IRFBSplineSurface
IRFEntity
Common interface of entity
SetID()/GetID()
Set/Get interfaces entity ID
INSEntityID ShellID;
IRFShell iSh;
iSh.SetID(ShellID);
ShellId =iSh.GetID();
Assert()
Check whether entity exist or not
if(iSh.Assert()!=true){
//shelldoesnotexist!
}
IRFEntity
Transform()
Transform entity with homogeneous transform matrix
CINSTMatrixmatrix(30*(PI/180),0,0,0,0,0);
iSh.Transform(matrix); //rotateshell30degreearoundxaxis.
GetMinMaxBox()
Get axis-aligned bounding box of entity
CINSBoxShBox;
iSh.GetMinMaxBox(ShBox);
xaxis
Rotation
IRFModel
Interface of the model
Single model support
Containing all kernel entities such as shells, curves and surfaces
IRFModel
Add entity to the model
AddShell()
IRFModel iMd;
INSEntityID shellID;
iMd.AddShell(INS_GENERIC_SHELL,shellname,shellID);
Delete entity of the model
DeleteShell(), DeleteShellAll(), DeleteBSplineCurve(), DeleteBSplineSurface()
iMd.DeleteShell(shellID);
iMd.DeleteBSplineCurve(curveID);
Get number of entities
GetNumOfShells(), GetNumOfBSplineCurves(), GetNumOfBSplineSurfaces()
int NumShells;
iMd.GetNumOfShells(NumShells);
Shell
Curve
Surface
IRFModel
Enumeration container
Includes entity IDs and current position in ID array
int Size() - Get number of entities
void Reset() - reset current position
INSEntityID Next() - return ID at current position & increase current position
CINSEnumEntities
Containing copied ID array of enumerated entities
Because of copying, enumeration can be slow when number of entities is
larger (i.e. vertices or faces of shell)
CINSEnumEntitiesConst
Constant version of CINSEnumEntities
Containing owner entitys array pointer directly, not copying it
Only available for vertices and faces
Modifying(adding or deleting) sub-entities of owner entity is not allowable.
IRFModel
Enumerate sub-entities of the model
Enumeration container pointer should be deleted after use.
EnumShells(), EnumCurves(), EnumSurfaces()
IRFModeliMd;
IRFShelliSh;
CINSEnumEntities*pEnumShells=NULL;
if(iMd.EnumShells(pEnumShells)==INSERROR_OK)
{
for(inti=0;i<pEnumShells>Size();i++)
{
iSh.SetID(pEnumShells>Next());
//addcodes
}
}
if(pEnumShells)
RFDELETE_AND_NULL(pEnumShells);
IRFShell
Interface of shell (point cloud or polygonal mesh)
Support only triangular mesh
Containing sub-entities such as vertices, faces and edges
Point cloud Polygonal mesh
Shell
IRFShell
Shell type
INS_GENERIC_SHELL
INS_MEASURED_SHELL
If the shell has a local coordinate (i.e. camera coordinate), shell should be
added to the model with this type.
When adding a vertex to the shell, the vertexs coordinate should be
global coordinate.
This property is used in 2D triangulate.
Z-direction is viewing direction of camera. (see 2D triangulation)
SetMeasuringCoordinate(), GetMeasuringCoordinate()
CINSPointOrgin;
CINSUnitVectorUaxis,Vaxis;
CINSCoordinateMeasureCoord;
iSh.SetMeasuringCoordinate(Origin.x,Origin.y,Origin.z,
Uaxis.x,Uaxis.y,Uaxis.z,Vaxis.x,Vaxis.y,Vaxis.z);
iSh.GetMeasuringCoordinate(MeasureCoord);
IRFShell
Add entity to the shell
AddFace(), AddVertex()
IRFShelliSh;
INSEntityIDVtID[3],FcID;
iSh.AddVertex(0,0,0,VtID[0]); //vertex1(0,0,0)
iSh.AddVertex(0,1,0,VtID[1]); //vertex2(0,1,0)
iSh.AddVertex(1,0,0,VtID[2]); //vertex3(1,0,0)
iSh.AddFace(VtID[0],VtID[1],VtID[2],true,FcID);
IRFShell
Delete entity of the shell
DeleteFace(), DeleteFaceAll(), DeleteVertex(), DeleteVertexAll()
DeleteDanglingVertexAll()
Delete all vertices which has no face
DeleteDanglingFaceAll(int nEdge= 3)
Delete all faces which has more edges than nEdge
iSh.DeleteFace(FcID);
iSh.DeleteVertex(VtID[0]);
iSh.DeleteDanglingVertexAll();
iSh.DeleteDanglingFaceAll(3);
IRFShell
Enumerate sub-entities of the shell
Enumeration container pointer should be deleted after use.
EnumLoops(), EnumFaces(), EnumEdgeUses(), EnumVertecies()
EnumAllVerticesConst(), EnumAllFacesConst()
Constant version
INSEntityIDShellID;
IRFShelliSh(ShellID);
CINSEnumEntitiesConst*pEnumFaces=NULL;
IRFFaceiFc;
if(iSh.EnumAllFacesConst(pEnumFaces)==INSERROR_OK)
{
for(inti=0;i<pEnumFaces>Size();i++)
{
iFc.SetID(pEnumFaces>Next());
//addcodes
}
}
if(pEnumFaces)
RFDELETE_AND_NULL(pEnumFaces);
IRFShell
Get geometric property
CalcArea(), CalcVolume(), IsClosed()
doubledArea,dVolume;
iSh.CalcArea(dArea);
iSh.CalcVolume(dVolume);
Set/Get property
SetLock(), IsLock()
Set/Get a lock status of the shell
In registration API, only unlocked shells are moving. (see align)
boolbLocked;
iSh.IsLock(bLocked);
iSh.SetLock(bLocked);
IRFShell
Update geometries of the shell
Below methods should be called once after modifying shell
CalcMinMaxBox()
Calculate axis-aligned box of shells
Regenerate(bool bMinMaxBox=true, bool bRegenNormal=true)
Update the min-max box of shell and the normal of vertex.
Includes CalcMinMaxBox(), if bMinMaxBox is true
IRFShell
CRFKDLumpTreeF
K-dimensional binary tree that represents hierarchically decomposed space by
half planes
It is used for searching min-distance vertex from point quickly.
CreateKDLumpTreeF(CRFKDLumpTreeF *&prKDTree)
classCRFKDLumpTreeF;
typedefstruct{
INSIDid; //vertexslowID
floatxyz[3];//vertexsposition
}KDTreeNodeF;
typedefstructqueueNode2F{
floatdist; //Squaredistance
KDTreeNodeF*elem;//elementtobefound
structqueueNode2F*next;
}KDLumpTreeQUEUEF;
Please note that farther point(vertex) comes first.
IRFShell
CRFKDLumpTreeF
IRFShelliSh(ShellID);
CRFKDLumpTreeF*pKDTree=NULL;
if(iSh.CreateKDLumpTreeF(pKDTree)==INSERROR_OK)
{
constintnDepth;//wewillfindthreeclosestvertex
KDLumpTreeQUEUEF*que,sque[nDepth+2];//queuetostoreclosestnodes,itssizeis
depth+2
boolbIgnoreOuterPoint=false;//ifitistrue,searchingisfastbutnotexact.
floatquery[3]={0.0f,0.0f,0.0f};//positiontosearchclosestvertices
if(pKDTree>Search(query,nDepth+1,sque,bIgnoreOuterPoint)){
for(que=sque[0].next>next;que!=NULL&&que>elem!=NULL;que=que>next)
{
//que>dist:squaredistance,que>elem>id:vertexslowid
//vertexsidisINSEntityID(iSh.GetLowID(),que>elem>id,0,ENTITY_VERTEX).
//addcode
}
}
}
if(pKDTree)
RFDELETE_AND_NULL(pKDTree);
IRFShell
CINSEncodedFaceSet
3D grid structure to encode face geometries spatially.
It is used for searching ray intersection position or closest position on face.
Only available for mesh shells.
CreateEncodedFaceSet(int Resolution/*=0*/, CINSEncodedFaceSet
*&prEncSet)
X
Y
Z
Resolution = 4
Infinite ray
IRFShell
CINSEncodedFaceSet
IRFShelliSh(ShellID);
CINSEncodedFaceSet*pEncFcSet=NULL;
if(iSh.CreateEncodedFaceSet(0,pEncFcSet)==INSERROR_OK)
{
boolbFound;
doubleSeedPt[3],SeedNorm[3],xPt[3],xS,xT,dSQDistance;
INSIDxFcID;
//SetSeedPt&SeedNorm
bFound=pEncFcSet>FindRayTriangleXPoint(SeedPt,SeedNorm,&xFcID,&xS,&xT,xPt,
true,false);
bFound=pEncFcSet>FindClosestFace(SeedPt,&xFcID,xPt,&xS,&xT,&dSQDistance);
/*xS,xTisbicentriccoordinate
xPt=(1xSxT)*P1+xS*P2+xT*P3=P1+xS*(P2P1)+xT*(P3P1)
(Here,P1,P2andP3arethepointsofFace)*/
}
if(pEncFcSet)
RFDELETE_AND_NULL(pEncFcSet);
IRFFace
Interface of face
Support only triangular mesh
The normal direction is defined by CCW.
Face
Vertex 1
Vertex 2
Vertex 3
Adj. Faces
Adj. Faces of
vertices 1,2 and 3
Face
Vertex 1
Vertex 2
Vertex 3
Adj. Faces
Non-manifold edge
More faces than three have a common edge
Two faces have a common vertex and non
common edge
Neighbor faces have each opposite directions
Non-manifold edge
IRFFace
Enumerate entities
GetShellID()
GetEdgeUses(INSEntityID *, INSEntityID *, INSEntityID *)
GetVertices(INSEntityID *, INSEntityID *, INSEntityID *)
EnumAdjacentFaces(CINSEnumEntities *&)
EnumAdjacentFacesOfVertices(CINSEnumEntities *&)
Face
Vertex 1
Vertex 2
Vertex 3
Adj. Faces
Adj. Faces of
vertices 1,2 and 3
IRFFace
Get geometric property
GetPoints(CINSPoint *, CINSPoint *, CINSPoint *)
CalcArea(), CalcMeanLengthOfEdges(), CalcCenter()
CalcNormal(CINSVector &rNormal, bool bAreaFactor = false);
Methods for topological property
ReverseNormal()
Reverse vertices order
IsDegenerate()
Whether zero-length edge is or not
IRFVertex
Interface of vertex
3D spatial coordinates
UV texture mapping coordinates
Vertex color
Vertex
Depth=1
Adj. Faces
Depth=2
Adj. Faces
Depth=1
Adj. Vertices
Depth=2
Adj. Vertices
IRFVertex
Enumerate entities
GetShellID()
GetNumOfAdjacentFaces(), EnumAdjacentFaces()
EnumDepthAdjacentFaces(int, CINSEnumEntities *&)
EnumAdjacentEdgeUses(), EnumAdjacentReverseEdgeUses()
GetNumOfAdjacentVertices(), EnumAdjacentVertices()
EnumDepthAdjacentVertices(int, CINSEnumEntities *&)
Vertex
Depth=1
Adj. Faces
Depth=2
Adj. Faces
Depth=1
Adj. Vertices
Depth=2
Adj. Vertices
IRFVertex
Get geometric property
GetPoint(), SetPoint()
GetColor(), SetColor()
SetNormal(), GetNormal()
CalcNormal(CINSUnitVector &rNormal, bool bIsAreaNormal = false)
Methods for topological property
IsBoundary()
HasRedundantFaces()
If # of adj. vts. < # of adj. fcs., this has redundant faces.
IsDegenerate()
If this vertex is one of the zero length edge, it is degenerated.
IRFEdgeUse
Interface of edge use
Start & end vertex.
Temporary entity this is not stored in the kernel DB.
Left face
Right face
Right vertex
Left vertex
Next EdgeUse
Previous EdgeUse
Start vertex
End vertex
Face
Vertex 1
Vertex 2
Vertex 3
Adj. Faces
Non-manifold edge
IRFEdgeUse
Enumerate entities
GetShellID()
GetType(INSEdgeUseType &rType)
INS_NORMAL_EDGEUSE: Edge having two faces
INS_BOUNDARY_EDGEUSE: Edge having one face
GetNumOfAdjacentFaces(), EnumAdjacentFaces()
GetLeftFace(), GetRightFace()
GetPrevEdgeUse(), GetNextEdgeUse()
GetStartVertex(), GetEndVertex(), GetVertices()
GetLeftVertexID(), GetRightVertexID()
GetSymEdgeUse()
Return reversed edge
Left face
Right face
Right vertex
Left vertex
Next EdgeUse
Previous EdgeUse
Start vertex
End vertex
Reversed edge
IRFEdgeUse
Get geometric property
GetStartPoint(), GetEndPoint(), GetPoints()
CalcDirection()
CalcLength()
CalcAngle()
Angle between left & right faces
CalcNormalAngle()
Angle between left & right faces normal
Method for topological property
IsBoundary(), IsManifold()
Entity Interfaces
NURBS(Non-uniform Rational B-Spline)
B-Spline Curve
B-Spline Surface
Degree(=order-1)
Control point
Homogeneous coordinate
Knot vector
IRFBSplineCurve
Interface of B-Spline Curve
Get geometric property
EvaluatePoint(), EvaluateTangent(), EvaluateCurvature(), EvaluateTorsion()
Evaluate value at given parameter
Reverse(), CalcLength()
ProjectPoint()
Project point to B-Spline curve
GetControlPoints(), SetControlPoints()
IRFBSplineCurve
Tessellate curve
GenerateInterpolationPoints(CArray<CINSPoint, CINSPoint&>&, double
dChordHeightTol)
Get tessellated points
This can be used for displaying a curve.
INSEntityIDcurveID;
IRFBSplineCurveiCurve(curveID);
doubledChordHeightTol=0.01;
CArray<CINSPoint,CINSPoint&>ArrTessPoints;
iCurve.GenerateInterpolationPoints(ArrTessPoints,dChordHeightTol);
IRFBSplineSurface
Interface of B-Spline Surface
Get geometric property
EvaluateTangent(), EvaluateCurvature(), EvaluateNormal(), EvaluatePoint()
Evaluate value at given parameter
Reverse()
ProjectPoint(), NormalizePoint()
Project point to B-Spline curve by shortest or normalized (orthogonal to
surface) method
GetControlPoints(), SetControlPoints()
IRFBSplineSurface
Tessellate surface
CalcAutoTessResolution(SRFSurfTessParam &, eRFSurfTessResolution)
Get tessellation option automatically
Tessellate(SRFSurfTessMesh&, SRFSurfTessParam)
Tessellate surface with given option
typedefenum
{
INS_SURFTESS_LOWEST=0,
INS_SURFTESS_LOW,
INS_SURFTESS_MEDIUM,
INS_SURFTESS_HIGH,
INS_SURFTESS_HIGHEST,
}eRFSurfTessResolution;
StructSRFSurfTessParam
{
ULONGlMinCurveDivisions;
doubledChordHeightTol;
doubledAngleTolInDegrees;
doubledMax3DEdgeLength;
doubledMin3DEdgeLength;
doubledMaxAspectRatio;
doubledMinUVRatio;
boolbIncBoundaries;
};
structSRFSurfTessMesh
{
intiNumMeshVts;
intiNumMeshFcs;
float*pfMeshVtsData;//iNumMeshVtsx3
float*pfMeshNormData;//iNumMeshVtsx3
int*piMeshFcsData;//iNumMeshFcsx3
//forboundaries
CArray<CArray<CINSPoint,CINSPoint&>*,
CArray<CINSPoint,CINSPoint&>*&>
*pArrBoundariesData;
};
IRFBSplineSurface
Tessellate surface
INSEntityIDsurfaceID;
IRFBSplineSurfaceiSurf(surfaceID);
SRFSurfTessParamTessParam;
SRFSurfTessMeshTessMesh;
IRFBSplineSurface::CalcAutoTessResolution(TessParam,INS_SURFTESS_LOW);
iSurf.Tessellate(TessMesh,TessParam);
PRIMITIVES
Primitives
Primitives
Represent 2D/3D geometries
Rapidform Library/Include/INSPrimitives/
Data type Description Data type Description
CINSPoint 3D Euclidean point CINSPoint2D 2D Euclidean point
CINSVector 3D direction vector CINSVector2D 2D direction vector
CINSUnitVector 3D direction unit vector CINSUnitVector2D 2D direction unit vector
CINSLine 3D finite line geometry CINSLine2D 2D finite line geometry
CINSPlane Infinite plane geometry CINSCoordinate 3D coordinate system
CINSCircle 3D circle geometry CINSCircleArc 3D circular arc geometry
CI NSSphere 3D sphere geometry CINSCylinder 3D finite cylinder geometry
CINSCone 3D finite cone geometry CINSBox 3D axis-aligned box geometry
CINSGeneralBox 3D box geometry CINSTorus 3D torus geometry
CINSTMatrix Homogeneous transform
matrix
GEOMETRIC CALCULATION APIS
Geometric Calculation APIs
class INSCGAPI
Rapidform Library/Include/INSCGAPI/INSCGApi.h
Distance methods
PointPointDistance(), PointLineDistance(), PointPlaneDistance(), etc
Comparison methods
IsParallelVector(), IsPointOnLine(), IsPointInTriangle(), etc
Intersection methods
LineLineXPoint(), LinePlaneXPoint(), PlanePlaneXLine(), etc
Projection methods
PointProjectionOnLine(), PointProjectionOnPlane(), etc
Geometric Calculation APIs
class CINSEigenSystem
Rapidform Library/Include/INSCGAPI/GeomEigenSystem.h
Get eigen values & vectors
SolveEigenSystemDecrSort3(), SolveEigenSystemDecrSort4(), etc
This method can be used for get principal axes
class CINSLSQFitAPI
Rapidform Library/Include/INSCGAPI/GeomLSQFit.h
Get least-square fitted geometries
LSQFitXXX() ;XXX=Geometry, ex. LSQFitCylinder()
Calculate error statistics
Min./Max./Avg./Var./Std.Dev. error
StatisticsOfXXX() ;XXX=Geometry, ex. StatisticsOfCylinder()
COMMAND APIS
Command APIs File IO
namespace RFCmdFileIOAPI
File I/O commands
New model
New()
Initialize the model
See OnNewDocument() @ APITestDoc.cpp
Import/Export entities
ImportFile(), ExportFile()
Import/Export the given entities from/to the given format file.
See OnFileImport(), OnFileExport() @ APITestDoc.cpp
ImportMDL(), ExportMDL()
Import/Export the all entities of the model from/to MDL file format
Command APIs File IO
Import Format
RapidForm Model File (*.mdl)
RapidForm Points File (*.pts)
RapidForm Polygons File (*.fcs)
Ascii Points File (*.asc)
3D Studio File (*.3ds)
AutoCAD DXF File (*.dxf)
CyberWare File (*.ply)
Inventor 1.0 ASCII File (*.iv)
STL File (*.stl)
VRML 1.0/97 File (*.wrl)
OBJ File (*.obj)
Hymarc File (*.hym)
Vivid File (*.vvd, *.cdk, *.cdm, *.cam)
Steinbichler File (*.ac)
GOM File (*.view, *.cloud, *.g3d)
Kreon File (*.cbk, *.grk, *.cwk)
3D Digital Corp. File (*.pmj, *.pmjx)
IGES File (*.iges, *.igs)
INUS Compression File (*.icf)
Breuckmann File (*.bre)
EOIS File (*.xyz, *.txt)
3D Scanners File (*.sab, *.sab2)
3DS MAX Ascii Export File (*.ase)
NEC Range Finder File (*.nrf, *.ntf)
STEP File (*.step, *.stp)
VDAFS File (*.vda)
Cyra File (*.pts, *.ptx)
Scantech File (*.stb)
Surf File (*.surf)
PICZA File (*.pix)
Opton File (*.xyz, *.crs, *.lin, *.smh, *.bin)
Perceptron File (*.swl, *.swb, *.bin)
DeltaSphere File (*.rtpi, *.xyzi, *.xyzrgb)
ShapeGrabber File (*.3pi)
Mensi File (*.soi)
Solutionix File (*.icv, *.snx)
Wicks and Wilson File (*.tfm)
iQvolution File (*.iqscan)
Riegl File (*.3dd)
Optimet File (*.opd)
Export Format
RapidForm Model File (*.mdl)
RapidForm Points File (*.pts)
RapidForm Polygons File (*.fcs)
Ascii Points File (*.asc)
STL File (*.stl)
3DS File (*.3ds)
OBJ File (*.obj)
IGES File (*.igs)
Command APIs Polygon
namespace RFCmdPolygonAPI
Point cloud & polygonal mesh commands
Pre-process
Filtering, Sampling
Align
Align initially, globally
Generate mesh
2D/3D triangulate, SCM
Merging, combining
Post-process
Filling holes
Re-meshing
Decimating
Point clouds or meshes
Pre-process
Align
Generate mesh
Post-process
Work Process
Command APIs Pre-process
Delete noisy vertices
FilterNoise(
const INSEntityID &rcShID,
double dMinClusterDist,
unsigned int iMaxClusterSize)
double dMinClusterDist
minimum distance between clusters.
unsigned int iMaxClusterSize
Delete clusters which have less vertices than this parameter.
See OnFilternoise() @ APITestDocMenu.cpp
Command APIs Pre-process
Delete noisy vertices
Exercise
Import FilterNoise.mdl
Run Mesh > Filter > Noise menu.
Command APIs Pre-process
Delete redundant vertices
FilterRedundancy (
const INSEntityID &rcShID,
double dRadius)
double dRadius
distance criteria to determine whether vertices are redundant
If this parameter is 0.0, it will be calculated automatically.
See OnFilterredundancy() @ APITestDocMenu.cpp
Command APIs Pre-process
Delete redundant vertices
Exercise
Import filter_redundancy.mdl
Run Mesh > Filter > Redundancy menu.
Command APIs Pre-process
Delete vertices for shell to have uniform density
UniformSampling (
const INSEntityID &rcShID,
double dSampleRatio,
RFSamplingType eSamplingType)
double dSampleRatio
the reduced vertex number to the original vertex number
RFSamplingType eSamplingType
RF_SAMPLE_GENERAL = Sampling of point set in order of point input
RF_SAMPLE_LINE_GRID = Sampling of point set by voxel after
dividing point set into voxel
See OnUniformsampling() @ APITestDocMenu.cpp
Command APIs Pre-process
Delete vertices for shell to have uniform density
Exercise
Import sampling.mdl
Run Mesh > Filter > Uniform Sampling menu.
Command APIs - Align
Align two shell initially
RegisterShellsQuick (
const INSEntityID &rcRefShID,
const INSEntityID &rcMovShID,
CINSTMatrix &rMovTMat)
Calculate the moving shell to the reference shell by using their principal
coordinate
CINSTMatrix rMovTMat
Result homogenous transform matrix
See OnRegistershellsquick() @ APITestDocMenu.cpp
Command APIs - Align
Align shells globally
RegisterShells (
const Carray<INSEntityID, INSEntityID&> &rcArrShIDs,
Carray<CINSTMatrix, CINSTMatrix&> &rArrTransforms,
double dLengthCriteriaMultiplier,
const SRFRegisterParam &rcParam)
Align moving shells to reference shells globally
locked status of shell (see shell interface) decide moving property.
Carray<CINSTMatrix, CINSTMatrix&> &rArrTransforms
Homogeneous transform matrix of each shells
The size of array will be same as input shells
double dLengthCriteriaMultiplier
Internal use
const SRFRegisterParam &rcParam
See OnRegistershells() @ APITestDocMenu.cpp
Command APIs - Align
Align shells globally
RegisterShells option
struct SRFRegisterParam
Bool m_bUseCustomMaxIteration
Int m_iCustomMaxIteration
Bool m_bUseCustomAveDeviation
double m_dCustomAveDeviation
bool m_bRemoveOutlier
bool m_bLockTransX
bool m_bLockTransY
bool m_bLockTransZ
bool m_bLockRotX
bool m_bLockRotY
bool m_bLockRotZ
Command APIs Align
Delete vertices for shell to have uniform density
Exercise
Import align.mdl
Run Mesh > Register> Quick menu.
Run Mesh > Register> Global menu.
After quick register After global register
Command APIs Generate mesh
2D Triangulate
Triangulate2D (
const INSEntityID &rcShID,
const SRFTriangulate2DParam &rcParam)
Apply Delaunay triangulation process with projected vertices on plane.
Z-direction is global Z-axis, but in measured shell z-direction is camera
direction. (see measured shell)
structRFAPISRFTriangulate2DParam
{
unsignedintm_uiVersion;
RFTriangulateDirection m_eDirectionOption;
CINSTMatrixm_CustomTransform;
bool m_bConstraintLength;
double m_dConstraintLength;
bool m_bConstraintArea;
double m_dConstraintArea;
bool m_bConstraintRatio;
double m_dConstraintRatio;
bool m_bConstraintAngle;
double m_dConstraintAngle;
};
enumRFTriangulateDirection{
RF_TRIANGULATE_DIRECTION_PLUS_Z=1,
RF_TRIANGULATE_DIRECTION_MINUS_Z,
RF_TRIANGULATE_DIRECTION_CUSTOM
};
Command APIs Generate mesh
2D Triangulate
Exercise
Import venus_point.mdl
Run Mesh > Triangulate > 2D menu.
Command APIs Generate mesh
3D Triangulate
EstimateTriangulate3DRadii (
const INSEntityID &rcShID,
CArray< double, double & > &ArrRadii)
Triangulate3D (
const INSEntityID &rcShID,
const CArray< double, double & > &ArrRadii,
bool bScanLineType)
Command APIs Generate mesh
3D Triangulate
Exercise
Import car.mdl
Run Mesh > Triangulate > 3D menu.
Command APIs Generate mesh
Generate mesh
SphericalCoverMesh (
const INSEntityID &ShID,
const SRFSCMParam &rcParam)
Struct SRFSCMParam
eSCMQuadricError m_eQError
Accuracy of result mesh
(sparse) SCM_Q_ERROR_1 < < SCM_Q_ERROR_7 (dense)
bool m_bUseNormal
bool m_bSmooth
bool m_bPreserveBoundary
bool m_bOptimize
Command APIs Generate mesh
Combine shells
CombineShells (
const CArray< INSEntityID, INSEntityID & > &rcArrShIDs,
INSEntityID &rResultShID,
const SRFTextureParam &rcTextureParam)
Combining method just adds vertices of other shells to one shell without
any topological change
INSEntityID rResultShID
Created combined shell ID
struct SRFTextureParam
unsigned int m_uiVersion
bool m_bPreserveTexture
int m_iTextureResolution
The resolution of newly created texture will be this parameter.
Command APIs Generate mesh
Combine shells
Exercise
Import point_merge.mdl
Run Mesh > Combine Shells menu.
Command APIs Generate mesh
Merge point clouds
MergeVertexShells(
const CArray<INSEntityID, INSEntityID&> &rcArrShIDs,
RFMergePointCloudShellOption eMergeOption,
INSEntityID &rResultShID)
Merging method combines input shells and reduces redundant vertices in
overlap region (topological change).
RFMergePointCloudShellOption eMergeOption
RF_MERGE_POINT_CLOUD_SHELL_MERGE
Input shells will be deleted
RF_MERGE_POINT_CLOUD_SHELL_COPY_AND_MERGE
Command APIs Generate mesh
Merge point clouds
Exercise
Import point_merge.mdl
Run Mesh > Merge Shells > Point Cloud menu.
Command APIs Generate mesh
Merge meshes
MergeShells (
const CArray< INSEntityID, INSEntityID & > &rcArrShIDs,
double dCritTolRatio,
INSEntityID &rResultShID,
const SRFTextureParam &rcTextureParam)
double dCritTolRatio
When faces are closer than dCritTolRatio * average length of face,
they will be merged.
Command APIs Generate mesh
Merge meshes
Exercise
Import venus_register_fine.mdl
Run Mesh > Merge Shells > Mesh menu.
Command APIs Generate mesh
Merge shells by volume method
VolumeMergeShells (
const CArray< INSEntityID, INSEntityID & > &rcArrShIDs,
double dResolution,
bool bUseAvgNormalProjection,
bool bOptimizeMesh,
INSEntityID &rNewShID,
const SRFTextureParam &rcTextureParam)
double dResolution
Voxel resolution(= Ratio to average edge length), (0.0, 1.0]
bool bUseAvgNormalProjection
Whether to average vertex normal vectors within a voxel or not
Command APIs Generate mesh
Merge shells by volume method
Exercise
Import volume_merge1.mdl, volume_merge2.mdl
Run Mesh > Merge Shells > Volume menu.
Command APIs Post-process
Fill holes of shell
FillHolesShell (
const INSEntityID &rcShID,
const SRFFillHoleParam &rcParam)
struct SRFFillHoleParam
unsigned int m_uiVersion
unsigned long m_ulNumMaxVts
Only loops whose vertices number is smaller than this parameter
will be filled
RFFillHoleMethod m_eMethod
RF_FILL_HOLE_PLANE
RF_FILL_HOLE_SMOOTH
RF_FILL_HOLE_CURVATURE
bool m_bSmoothBoundary
bool m_bExceptLargestHole
Command APIs Post-process
Fill holes of shell
Exercise
Import helmet.mdl
Run Mesh > Fill holes > Shell menu.
Command APIs Post-process
Fill holes of shell by volume method
VolumeFillHolesShell (
const INSEntityID &rcShID,
const SRFVolumeFillHoleParam &rcParam)
struct SRFVolumeFillHoleParam
unsigned int m_uiVersion;
double m_dResolution
Voxel resolution(= Ratio to average edge length), (0.0, 1.0]
unsigned int m_iIteration
bool m_bExceptLargestHole
bool m_bOptimizeMesh
Command APIs Post-process
Fill holes of shell by volume method
Exercise
Import volume_fillhole1.mdl
Run Mesh > Fill Holes > Volume Shell menu.
Command APIs Post-process
Reduce the number of face of shell
DecimateShell (
const INSEntityID &rcShID,
double dReductionRatio,
double dAllowableDeviation,
const SRFDecimateParam &rcParam)
Two operation modes
Reduction ratio
specifies the percentage of the faces to be retained.
Allowable deviation
specifies the allowable amount of the vertex displacement
during decimation.
If this value is positive, API will works this mode.
Command APIs Post-process
Reduce the number of face of shell
DecimateShell options
double dReductionRatio
Ratio of decimation; (0, 1)
double dAllowableDeviation
Demanding error bound
struct SRFDecimateParam
Bool m_bPreserveVertices
Bool m_bPreserveBoundary
Bool m_bPreserveQuality
Bool m_bPreserveMark
Int m_iCurvatureBalance
[preserve high curvatures] 1 < < 6 [Regular mesh]
Bool m_bPreserveColor
int m_iColorBalance
Demanding color balance; [1, 3]
Higher color balance, preserve color more than geometry
Bool m_bPreserveTexture
Int m_iTextureResolution
Command APIs Post-process
Reduce the number of face of shell
Exercise
Import helmet_decimated.mdl
Run Mesh > Decimate > Shell menu.
Command APIs Post-process
Re-triangulate shell to improve quality
GlobalRemesh (
const INSEntityID &ShID,
const SRFGlobalRemeshParam &rcParam)
struct SRFGlobalRemeshParam
double m_dVoxelEdgeLength
bool m_bPreserveTexture
int m_iTextureResolution
Command APIs Post-process
Re-triangulate shell to improve quality
Exercise
Import helmet_decimated.mdl
Run Mesh > Remesh > Shell menu.
Command APIs Post-process
Re-triangulate shell to improve quality by volume method
GlobalVolumeHealing (
const INSEntityID &ShID,
const SRFGlobalVolumeHealingParam &rcParam)
struct SRFGlobalVolumeHealingParam
bool m_bResolutiontype
double m_dResolution
If m_bResolution is true, m_dResolution is the ratio to average edge
length. (0.0, 1.0]
If m_bResolution is false, m_dResolution is the size of voxel
bool m_bOptimizeMesh
bool m_bSmooth
bool m_bDeleteSmallCluster
bool m_bMultipleRangeDataMode
If m_bMultipleRangeDataMode is true, overlap regions are merged
smoothly.
bool m_bPreserveColorInfor
bool m_bPreserveBoundary
bool m_bPreserveTexture
intm_iTextureResolution
Command APIs Polygon Wizard
Mesh Generation Wizard (recommended process)
Batch process of the mesh generation process
See OnMeshgenerationwizard() @ APITestDocMenu_MeshWizard.cpp
Mesh > Mesh Generation Wizard menu
Registration
Combine (+ make point-cloud shells)
SCM (+ backup result shell)
Remeshing
Subdividing
Refitting to backup shell
(+ remove backup shell)
Enhancing
Decimating
Command APIs - Curve
namespace RFCmdCurveAPI
Curves commands
Create section curve
CreateSliceCurve(
const INSEntityID &rcShellID,
const CINSPlane &rcPlane,
unsigned long ulMaxCurveCount,
CArray<INSEntityID, INSEntityID&> &rArrResultCvIDs)
Create section curve of point cloud or polygonal shell
The maximum number of section curves to be created is ulMaxCurveCount.
See OnCreateslicecurve() @ APITestDocMenu.cpp
Command APIs - Curve
Create section curve
Exercise
Import shoe_last.mdl
Run Curve > Slice menu.
Command APIs - Surface
namespace RFCmdSurfaceAPI
CreatSurfaceByAutomatic(
const SRFAutoSurfacingOption &rcOption,
CArray<INSEntityID, INSEntityID&> &rArrResultSfIDs)
See OnCreatsurfacebyautomatic() @ APITestDocMenu_AutoSurfacing.cpp
structSRFAutoSurfacingOption{
unsignedintm_uiVersion;
INSEntityIDm_OrgShID;
INSEntityIDm_RefShID;
CArray<INSEntityID,INSEntityID&>*m_pArrFeatureCurves;
boolm_bIgnoreUnmatchedPatchError;
intm_iNumSurfaces;
intm_iNumCtrlPts;
intm_iFitAccuracy; //rangesfrom0to9
intm_iCaptureAccuracy; //rangesfrom0to2
boolm_bInitialRelax;
boolm_bGlobalMatch;
boolm_bRemoveSharpPatch;
}
Command APIs - Surface
namespace RFCmdSurfaceAPI
About 1000 patches of surface, double the number of polygon mesh, will
be created
Auto surfacing
Original shell Reference shell
Auto surfacing
Command APIs - Surface
Exercise
Import duct_auto.mdl
Run Surface > Automatic menu
Command APIs - Inspect
namespace RFCmdInspectAPI
CalcModelDev(
const CLumpArray<INSEntityID, INSEntityID&> &rcArrRefSh,
const CLumpArray<INSEntityID, INSEntityID&> &rcArrDevSh,
CLumpArray<CRFMDShVtMapF *, CRFMDShVtMapF *&> &rArrModelDev,
double dMaxSearchDev, bool bUseNormal=true)
Command APIs - Inspect
namespace RFCmdInspectAPI
CalcModelDev results
CINSMap<INSID, INSID, CRFMDVtF, CRFMDVtF&>
INSID = vertex low ID
CRFMDVtF = deviation value
Class CRFMDVtF
unsigned long m_iNumDev
float m_dDev = dummy
float m_dMaxDev = max signed deviation
float m_dSumDev = sum signed deviation
float m_dMinDev = min signed deviation
float m_duMaxDev = max unsigned deviation
float m_duSumDev = sum unsigned deviation
float m_duMinDev = min unsigned deviation
Command APIs - Inspect
namespace RFCmdInspectAPI
CalcWholeDeviation(
const INSEntityID &rcScanShID,
const CLumpArray<INSEntityID, INSEntityID&> &rcArrDesignIDs,
const SRFWholeDevParam &rcOption,
CINSMap<INSID, INSID&, CRFWholeDevResult, CRFWholeDevResult&>
&rWholeDevMap)
Command APIs - Inspect
namespace RFCmdInspectAPI
CalcWholeDeviation option
struct SRFWholeDevParam
double m_dMaxEdgeLength = Surface Tessellation option
double m_dMaxChordLength = Surface Tessellation option
INS_PROJECTION_METHOD m_ePrjMethod
PROJECTION_NORMALIZE_METHOD
PROJECTION_MINDIST_METHOD
PROJECTION_X_DIRECT_METHOD
PROJECTION_Y_DIRECT_METHOD
PROJECTION_Z_DIRECT_METHOD
INS_UNPROJECTION_METHOD m_eUnPrjMethod
UNPROJECTION_LEAVE_METHOD
UNPROJECTION_PLANE_METHOD
UNPROJECTION_EDGE_METHOD
double m_dMaxSearchDev
X-axis
Command APIs - Inspect
PROJECTION_MINDIST_METHOD
: minimum distance
PROJECTION_NORMALIZE_METHOD
: 180 degree
between a project direction and a surface normal
PROJECTION_X_DIRECT_METHOD
: YZ Plane projection
PROJECTION_Z_DIRECT_METHOD
: XY Plane projection
PROJECTION_Y_DIRECT_METHOD
: XZ Plane projection
Y-axis
Z-axis
Command APIs - Inspect
namespace RFCmdInspectAPI
CalcWholeDeviation results
CINSMap<INSID, INSID&, CRFWholeDevResult, CRFWholeDevResult&>
INSID = vertex low ID
CRFWholeDevResult = deviation value
class CRFWholeDevResult
CINSPoint m_PrjPt
Double m_PrjDist
INSID m_PrjID
DISPLAY
Display
See DrawShell() @ APITestView.cpp
Enumerate all faces or vertices
Draw face or vertex
See DrawCurve() @ APITestView.cpp
Calculate tessellated curve points
Draw points
See DrawSurface() @ APITestView.cpp
Calculate tessellated surface mesh
Draw mesh
openGL display list can be used.
User should update display list when entity is modified.
SELECTION
Selection
See class CAPITestPick @ APITestPick.h/cpp
Load Name which is low ID of entity
Use glLoadName()
Draw entity
ETC.
Etc.
Include directories
INSTemplate includes basic template and macro functions and C++ containers.
INSBase includes basic definitions and calculation tolerance manager.
INSMatrix include matrix classes.
INSPrimitives include primitive geometry classes.
INSCGAPI includes mathematical APIs.
INSGDB include definitions of entity, IDs and other C++ containers.
INSSystemAPI include definitions for visualization materials.
INSRapidForm include interfaces of all entity types and command APIs.
Help document
Installed directory\Documents\Rapidform.dll.chm
Example application
Installed directory\Example Application\APITest\
Thank you
Q & A

You might also like