VTK: Initiate List or Array of 3x3 matrices - vtk

The title said it all, can I make a list or array of 3x3 matrices? if so, how? I have tried using vtkSmartPointer<vtkDataArrayTemplate<vtkMatrix3x3>> inV = vtkSmartPointer<vtkDataArrayTemplate<vtkMatrix3x3>>::New();.Then it gives me error like below,
1>c:\vtk\src\common\core\vtkTypedDataArray.h(68): error C2027: use of undefined type 'vtkTypeTraits<T>'
1>with
1>[
1> T=vtkMatrix3x3
1>]
1>c:\vtk\src\common\core\vtkTypeTemplate.h(38) : see reference to class template instantiation 'vtkTypedDataArray<Scalar>' being compiled
1>with
1>[
1> Scalar=vtkMatrix3x3
1>]
1>C:\vtk\src\Common\Core\vtkDataArrayTemplate.h(35) : see reference to class template instantiation 'vtkTypeTemplate<ThisT,BaseT>' being compiled
1>with
1>[
1> ThisT=vtkDataArrayTemplate<vtkMatrix3x3>,
1> BaseT=vtkTypedDataArray<vtkMatrix3x3>
1>]
1>C:\vtk\src\Common\Core\vtkSmartPointer.h(117) : see reference to class template instantiation 'vtkDataArrayTemplate<T>' being compiled
1>with
1>[
1> T=vtkMatrix3x3
1>]
1>C:\vtk\src\Common\Core\vtkSmartPointer.h(116) : while compiling class template member function 'vtkSmartPointer<T> vtkSmartPointer<T>::New(void)'
1>with
1>[
1> T=vtkDataArrayTemplate<vtkMatrix3x3>
1>]
Thanks..

Okay, I can achieve that using combination of C++ and VTK.
vtkMatrix3x3 **mat = new vtkMatrix3x3*[src_obj->getObject()->GetNumberOfCells()];
Any better approach will be marked as correct answer..

What the error says is that when you want to create a vtkDataArrayTemplate<T>, it involves creating the following classes:
vtkTypeTraits<T>, and vtkTypedDataArray<T>, and those 2 classes expect a scalar as template parameter T.
You are giving it a Matrix of 9 values, so it can't work.
The vtkDataArrayTemplate class is mainly designed to contain scalars.
You can create an array of vtkMatrix3x3 more easily by using for example an std::vector :
std::vector<vtkMatrix3x3> inV;

Related

Where does the variable "name" come from?

Sample Code:
from enum import Enum
class Countries(Enum):
Afghanistan = 44
Andorra=88
Austrailia=38
print(Countries.Afghanistan.name)
output:Afghanistan
Question: Where is the variable "name" defined ? I couldn't locate in the source code of Enum which was very complicated anyway.
EnumMeta will use the names found in self._member_names as the enumeration member names. This defined values can be found at line 170 of enum.py.
But I could be wrong...
Enum is a class in python for creating enumerations, which are a set of symbolic names (members) bound to unique, constant values. The members of an enumeration can be compared by these symbolic anmes, and the enumeration itself can be iterated over. An enum has the following characteristics.
The enums are evaluatable string representation of an object also
called repr().
The name of the enum is displayed using ‘name’ keyword.
Using type() we can check the enum types.
I hope this will be helpfull for you.

OpenFL: Array has no field sortOn

I'm using OpenFL and I'm attempting to use this code I found...
pos.sortOn("cotangent", Array.NUMERIC | Array.DESCENDING);
...but I'm getting the error:
src/Main.hx:180: characters 2-12 : Array<{ yPoint : Float, xPoint : Float, cotangent : Float }> has no field sortOn
src/Main.hx:180: characters 26-39 : Class<Array> has no field NUMERIC
src/Main.hx:180: characters 42-58 : Class<Array> has no field DESCENDING
Now according to this 'sortOn' is an available method for AS3 arrays so what is the problem?
In Haxe you could use ArraySort.
Something like here
Haxe has a builtin standard Array class, which is what you're referencing, not AS3's Array. The Haxe Array is documented here: http://api.haxe.org/Array.html
If you don't care about a stable sort, you can use the sort method: http://api.haxe.org/Array.html#sort

Drawing app - intellisense error

so im making a drawing app and i have a last error - intellisense. This is the error:
IntelliSense: no instance of overloaded function "System::Drawing::Graphics::DrawLine" matches the argument list
argument types are: (System::Drawing::SolidBrush, System::Drawing::Point, System::Drawing::Point)
object type is: System::Drawing::Graphics
This is the code/ line:
g->DrawLine(SolidBrush(colorSel), oldPosition, e->Location);

An obscure corner of the Haskell Report

Section 5.2 of the Haskell 2010 Report deals with module export lists. At one point, it says:
Entities in an export list may be named as follows:
A value, field name, or class method, whether declared in the module body or imported, may be named by giving the name of the value as a qvarid, which must be in scope. Operators should be enclosed in parentheses to turn them into qvarids.
...
But, uh... am I missing something? Because according to the Syntax Reference in Chapter 10:
qvarid → [ monid . ] varid
varid → ( small { small | large | digit | ' })
So in which universe does putting an operator in brackets turn it into a qvarid? It looks to me like an operator is clearly a varsym (or maybe qvarsym).
Does anybody know what's going on here? I mean, clearly Haskell definitely supports writing operators in an export list, but the syntax description in the Report doesn't appear to make sense...
Wait, hold up... According to the Control-Free Syntax given in section 10.5:
export → qvar | qtycon ... | qtycls ... | module monid
...
var → varid | ( varsym )
qvar → qvarid | ( qvarsym )
So it seems that it's not a qvarid, it's supposed to be a qvar. So it's just a typo, I guess? Is there a process for having such things fixed in the official report?

groovy compile error

class x{
public static void main(String[] args){
String x="<html><head></head></html>";
String arr[]=x.split("<head>");
String script="hi";
x=arr[0]+"<head>"+script+arr[1];
System.out.println(x);
}
}
the above code when compiled as a java file compiles fine but when used a s a groovy file spits the error :
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
D:\Garage\groovy-binary-1.7.1\groovy-1.7.1\bin\x.groovy: 4: Apparent variable 'a
rr' was found in a static scope but doesn't refer to a local variable, static fi
eld or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable fro
m a static context.
You misspelled a classname or statically imported field. Please check the spelli
ng.
You attempted to use a method 'arr' but left out brackets in a place not allowed
by the grammar.
# line 4, column 10.
String arr[]=x.split("");
^
D:\Garage\groovy-binary-1.7.1\groovy-1.7.1\bin\x.groovy: 6: Apparent variable 'a
rr' was found in a static scope but doesn't refer to a local variable, static fi
eld or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable fro
m a static context.
You misspelled a classname or statically imported field. Please check the spelli
ng.
You attempted to use a method 'arr' but left out brackets in a place not allowed
by the grammar.
# line 6, column 5.
x=arr[0]+""+script+arr[1];
^
D:\Garage\groovy-binary-1.7.1\groovy-1.7.1\bin\x.groovy: 6: Apparent variable 'a
rr' was found in a static scope but doesn't refer to a local variable, static fi
eld or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable fro
m a static context.
You misspelled a classname or statically imported field. Please check the spelli
ng.
You attempted to use a method 'arr' but left out brackets in a place not allowed
by the grammar.
# line 6, column 28.
x=arr[0]+""+script+arr[1];
^
3 errors
D:\Garage\groovy-binary-1.7.1\groovy-1.7.1\bin>
It works if you move the [] to the String side like so:
String[] arr = x.split("<head>");

Resources